Try it free

dtctl CLI

  • Latest Dynatrace
  • App
  • 8-min read
  • Published Sep 04, 2026

dtctl is the Dynatrace command-line tool.

It brings your Dynatrace platform one command away, so you can manage workflows, dashboards, DQL queries, SLOs, and more from your terminal, from a script, or from an AI agent. It's for anybody who wants to use Dynatrace platform functionality via CLI, set up CI/CD pipelines that read or write Dynatrace data, or integrate Dynatrace with AI coding assistants.

This page provides an introduction to dtctl. For more information, see the relevant pages in the dtctl GitHub repository:

  • Per-resource reference: a full reference of all available resources, including supported operations, flags, output, required token scopes, and examples.
  • Detailed guides with steps to install, configure, and run dtctl for various use cases.

Prerequisites

To use dtctl, you need:

  • An active Dynatrace SaaS environment running Latest Dynatrace.

  • OAuth or token credentials with the required scopes for your use case.

    • To create an OAuth2 client, see OAuth clients.
    • To set up a platform token, see Platform tokens.
    • For more information, see Working with policies.

dtctl is compatible with Dynatrace SaaS environments only.

If you have a Dynatrace Managed environment, use dtmgd instead, because it's designed specifically for Managed environments.

Get started

You can install dtctl, set up authentication, verify connectivity, and run command examples for common use cases.

Install dtctl

Install dtctl with a single command. This page describes how to install dtctl on macOS, Linux, or Windows.

For binary downloads, building from source, and shell completion setup for bash, Zsh, Fish, and PowerShell, see the complete installation guide in the GitHub repository.

  1. Choose the method that fits your platform.

    • macOS and Linux

      • With Homebrew (also sets up shell completions):

        > brew install dynatrace-oss/tap/dtctl
      • Without Homebrew:

        > curl -fsSL https://raw.githubusercontent.com/dynatrace-oss/dtctl/main/install.sh | sh
    • Windows PowerShell

      irm https://raw.githubusercontent.com/dynatrace-oss/dtctl/main/install.ps1 | iex

    Restart your terminal afterward so the updated PATH takes effect.

  2. Verify the binary is on your PATH.

    > dtctl version

    The output will show the dtctl version, relevant Git commit, and date that the binary was built.

Set up authentication

You can authenticate via OAuth or platform tokens, and also pass credentials through environment variables:

  • In most cases, Dynatrace recommends to use browser-based OAuth login with your Dynatrace SSO credentials.
  • In cases where OAuth isn't possible, such as in headless environments, you can also use platform tokens.
  • You can also pass credentials through environment variables (DTCTL_ENVIRONMENT, DTCTL_TOKEN) without running interactive commands. Multi-environment setup, safety levels, and per-project config files are covered in the configuration reference.

To authenticate via OAuth:

  1. Find your environment URL. Your environment URL has the form https://<environment-id>.apps.dynatrace.com.

  2. Log in and create a context. A context names an environment and its credentials so you can switch between them later.

    > dtctl auth login --context my-env --environment "https://abc12345.apps.dynatrace.com"
  3. Complete the login in your browser. dtctl opens your browser for SSO login and stores the returned tokens in your OS keyring.

  4. Use dtctl doctor to check that dtctl can reach the environment, that your credentials are valid, and that your token carries the scopes common commands need.

    > dtctl doctor

    An example output is shown below.

    [OK] dtctl version 0.39.0 (commit: 2aae6cc, built: 2026-09-18T21:31:33Z)
    [OK] Configuration /Users/alex.example/Library/Application Support/dtctl/config
    [OK] Current context my-env (environment: https://abc12345.apps.dynatrace.com, safety: readwrite-all)
    [OK] Environment URL URL pattern looks correct
    [OK] Token storage macOS Keychain
    [OK] Token retrieved from keyring (macOS Keychain) (eyJh...Jz4g)
    [OK] OAuth session access expires in 4m54s; refresh token present
    [OK] Connectivity https://abc12345.apps.dynatrace.com is reachable
    [OK] Authentication authenticated as c4f3c4f3-c4f3-c4f3-c4f3-c4f3c4f3c4f3 (alex.example@email.com)

Concepts

Syntax

dtctl uses a predictable verb-noun syntax inspired by kubectl. If you know kubectl, you already know how dtctl is organized, and so does any AI agent trained on the same conventions.

  • Verb-noun commands: A consistent grammar across every resource type, so command shapes are easy to predict and script
  • Agent-ready output: A structured JSON envelope (--agent) and a machine-readable command catalog (dtctl commands) that let AI agents operate Dynatrace reliably
  • Multi-environment: Named contexts for dev, staging, and production, with client-side safety levels that guard against accidental changes
  • Open source: Apache 2.0, developed in the open at dynatrace-oss/dtctl, with versioned releases

Supported resources

dtctl operates on the resource types below. The resource reference, with supported operations, flags, output, required token scopes, and examples, is available in the linked GitHub repository.

ResourceWhat you do with it

Workflows

Automate tasks: list, create, edit, run, and inspect workflow executions and their logs.

DQL queries

Run Dynatrace Query Language against Grail, with template variables, live mode, and large-result spill.

Dashboards and notebooks

Create, edit, share, version, and restore dashboards and notebooks.

SLOs

Define, apply, and evaluate service-level objectives.

Settings

Read schemas and get, create, update, and delete Settings objects.

Cloud integrations

Connect and monitor AWS, Azure, and Google Cloud accounts.

Grail buckets

Create, manage, and watch Grail storage buckets.

Filter segments

Manage reusable filter segments for queries and dashboards.

Lookup tables

Manage lookup tables, with CSV auto-detection on apply.

Extensions

Manage Extensions 2.0 and Hub extensions and their monitoring configurations.

App Engine

Discover and run app functions and intents, and open deep links into apps.

Analyzers

Run Davis statistical analyzers on your data.

Davis CoPilot

Chat with Dynatrace Assist, convert natural language to DQL, and search documents.

Anomaly detectors

Create, edit, and manage anomaly detectors.

Live Debugger

Set breakpoints, filter workspaces, and decode snapshots.

Documents and trash

Manage platform documents and restore items from trash.

EdgeConnect

Create, describe, and delete EdgeConnect configurations.

Notifications

Get, describe, delete, and watch platform notifications.

API discovery

Explore the APIs an environment publishes and inspect individual operations.

Platform tokens

Create, list, and delete account platform tokens.

Users and groups

Look up users and groups.

Use dtctl with AI agents

dtctl is built to be operated by AI coding agents as well as people. It exposes a structured output mode, auto-detects agent environments, ships a machine-readable command catalog, and bundles an installable Agent Skill.

Agent mode

The --agent flag (short form -A) wraps every response in a structured JSON envelope with an ok flag, a result payload, stable error codes, and follow-up suggestions. This lets an agent parse responses, branch on errors, and pick a next action without scraping human-readable text. Agent mode also implies --plain, so there are no colors, prompts, or spinners.

dtctl enables agent mode automatically when it detects a known agent environment, such as Claude Code, GitHub Copilot, Cursor, or OpenCode, based on environment variables those tools set. Use --no-agent to force human-readable output.

To bootstrap an agent's knowledge of the command surface, use the built-in catalog:

> dtctl commands # minimal overview of verbs, resources, and subcommands
> dtctl commands --brief -o json
> dtctl commands --full -o json

You can also use dtctl inventory, which answers "what is there to query?".

dtctl inventory probes the current environment read-only for fetchable data, buckets, segments, and capabilities. For more information, see Use cases.

Agent skills

dtctl ships an agent skill that teaches AI assistants how to use dtctl and Dynatrace. Install it with dtctl itself or through the skills registry:

> dtctl skills install # auto-detects your AI agent
> dtctl skills install --for claude # or specify the agent
> dtctl skills install --global # user-wide installation
> npx skills add dynatrace-oss/dtctl

The skill is compatible with GitHub Copilot, Claude Code, OpenAI Codex CLI, Cursor, Kiro, Junie, OpenCode, and other Agent Skills-compatible tools. For the full JSON envelope contract and detection details, see the AI agent mode documentation and AI agent skills documentation, plus the skills directory in the GitHub repository.

Use cases

The examples below span several resource types. Output is shown in its default table form unless a structured format is requested. Add -o json, -o yaml, -o csv, or --agent to any command for machine-readable output.

If a command fails with an authentication or permission error, run dtctl doctor first.

It pinpoints whether the problem is connectivity, an expired or missing login, or an insufficient token scope, and prints the next step to take. Add dtctl auth whoami to confirm which identity is active, and --check-scopes on any command to see the scopes it requires without running it.

List all workflows

> dtctl get workflows
ID NAME STATE LAST RUN
wf-abc123 Daily Health Check enabled 2026-09-03 06:00
wf-def456 Release Gate enabled 2026-09-03 12:15

Run a DQL query against Grail

> dtctl query "fetch logs | limit 10"
TIMESTAMP LOGLEVEL CONTENT
2026-09-03 12:14:59 ERROR Connection reset by peer
2026-09-03 12:14:58 INFO Request completed in 42ms

Get dashboards as JSON for automation

> dtctl get dashboards -o json
{
"dashboards": [
{ "id": "dash-001", "name": "Service overview", "owner": "team-a" }
]
}

Preview a declarative apply before it runs

> dtctl apply -f workflow.yaml --dry-run
+ workflow "Nightly backup" would be created
trigger: schedule (0 2 * * *)

Discover what data an environment holds before you query it

> dtctl inventory
BUCKETS 12
SEGMENTS 8
ENTITY TYPES HOST, SERVICE, PROCESS_GROUP, ...
CAPABILITIES logs: present, metrics: present, spans: present

Convert natural language to DQL with Dynatrace Assist

> dtctl exec copilot nl2dql "error logs from the last hour"
fetch logs
| filter loglevel == "ERROR"
| filter timestamp > now() - 1h

To get structured output for scripts and agents, do not parse the table output. Request -o json or --agent and read the fields directly.

See output formats for the full set of formats and the agent envelope.

Flags and environment variables

This section provides a short reference for all dtctl flags and required environment variables. For complete reference documentation, see the command reference in the GitHub repository.

Global flags

These flags apply to every dtctl command.

FlagDescription

--agent, -A

Agent output mode: wrap output in a structured JSON envelope with metadata.

--no-agent

Disable auto-detected agent mode and return human-readable output.

--output, -o

Output format: json, yaml, csv, toon, table, or wide. Defaults to table.

--jq

Apply a jq filter to structured output. Non-structured formats are auto-promoted to JSON.

--plain

Plain output for machine processing: no colors and no interactive prompts.

--context

Use a specific context for this invocation. Reads DTCTL_CONTEXT and is never persisted.

--config

Config file to use. Searches for .dtctl.yaml upward, then the global config.

--dry-run

Print what would be done without doing it.

--check-scopes

Check that the active token has the scopes this command requires, then exit without running it.

--chunk-size

Paginate through all results in chunks of this size. 0 returns only the first page. Defaults to 500.

--verbose, -v

Verbose output. Use -v for details, -vv for full debug including auth headers.

--debug

Enable debug mode with full HTTP request and response logging. Equivalent to -vv.

Environment variables

dtctl reads the following environment variables. Use them to configure dtctl without interactive commands, which is convenient for containers and CI/CD.

VariablePurpose

DTCTL_ENVIRONMENT

Environment URL to use when no context is configured interactively.

DTCTL_TOKEN

Platform token to authenticate with when no context is configured interactively.

DT_ENVIRONMENT_URL

Environment URL placeholder referenced by dtctl config init scaffolds.

DT_API_TOKEN

Platform token placeholder referenced by dtctl config init scaffolds.

DTCTL_ACCOUNT_TOKEN

Account API token for Account Management operations, such as platform tokens.

DTCTL_ACCOUNT_UUID

Account UUID for account-scoped operations.

DTCTL_CONTEXT

Context to use for this invocation. Never persisted.

DTCTL_CONFIG

Explicit, trusted config file path. Bypasses auto-discovery and honors aliases and apply hooks.

DTCTL_PROFILE

Command profile to activate, which limits the exposed command surface.

DTCTL_OUTPUT

Default output format when --output is not set.

DTCTL_SPILL

Large-result spill mode for dtctl query: auto, always, or never.

DTCTL_SPILL_DIR

Directory for spilled query results.

DTCTL_TOKEN_STORAGE

Set to file to store tokens on disk when an OS keyring is unavailable.

DTCTL_DISABLE_KEYRING

Disable use of the OS keyring for token storage.

DTCTL_INSTALL_DIR

Install directory override for the shell installer script.

DTCTL_EXPERIMENTAL_SERVE

Set to 1 to enable the experimental dtctl serve http command.

NO_COLOR and FORCE_COLOR

Disable or force colored output. dtctl also auto-detects whether it is writing to a terminal.

Related topics

Go deeper with dtctl by exploring the GitHub repository.

  • Source code, releases, and the full functional documentation set: dtctl on GitHub
  • Every verb, flag, resource type, and alias: Command reference
  • Contexts, credentials, safety levels, apply hooks, and aliases: Configuration
  • Required API token scopes per safety level: Token scopes
  • W3C trace context, OTLP span export, and CI/CD integration: Observability
  • Versioned release notes and downloadable binaries: Releases
  • Worked, end-to-end examples that combine multiple dtctl flags and commands to solve a specific problem: Cookbook

Related topics

  • Dynatrace MCP server
  • Dynatrace API
Related tags
Dynatrace Platform