| name | dtmgd |
| description | Query and investigate Dynatrace Managed (self-hosted) environments from the CLI. Use this skill when the user asks about problems, incidents, entities, events, logs, metrics, SLOs, or security vulnerabilities in a Dynatrace Managed cluster — even if they don't mention dtmgd by name. Covers connectivity checks, entity topology, time-series metric queries, log search, and full feature parity with the Dynatrace Managed MCP Server. |
Dynatrace Managed CLI — dtmgd
dtmgd is a kubectl-inspired read-only CLI for Dynatrace Managed (self-hosted) clusters.
It mirrors the full tool set of the Dynatrace Managed MCP Server as shell commands.
Recommended Initialization
At the start of any investigation, run these to confirm connectivity and current context:
dtmgd ctx
dtmgd get environments
dtmgd version
Agent mode is auto-detected — output will be wrapped in {ok, result, context} envelopes automatically.
Output Formats
Use -o json for AI/script consumption. Default is human-friendly table.
-o table
-o wide
-o json
-o yaml
AI Agent Envelope Mode
dtmgd auto-detects AI agent environments (Claude Code, Cursor, GitHub Copilot,
Amazon Q, Kiro, Junie, OpenCode) and wraps all output in a structured envelope:
{
"ok": true,
"result": { "problems": [...], "totalCount": 5 },
"context": { "resource": "problems" }
}
Errors are also wrapped: {"ok": false, "error": {"code": "error", "message": "..."}}.
Force with -A/--agent, disable with --no-agent.
Tip for AI agents: prefer -o json or -A when parsing results:
dtmgd get problems --status OPEN -o json
dtmgd describe problem <uuid> -A
Global Flags
-c, --context <name> override the current context (environment)
-e, --env <spec> target environment(s): name, "prod;staging", or ALL_ENVIRONMENTS
-o, --output <format> table | wide | json | yaml
-A, --agent force agent envelope output
--no-agent disable auto-detected agent mode
--max-pages <n> max pages to fetch (0 = all). Pagination is automatic.
--columns <cols> comma-separated columns to show in table output
-w, --watch re-run the command periodically
--watch-interval <d> interval between watch refreshes (default: 5s)
-v verbose: show HTTP request/response summary
-vv extra verbose: full headers + body (auth redacted)
--config <file> use a specific config file instead of the default
Multi-Environment Queries
Query multiple environments in parallel with --env:
dtmgd get problems --env ALL_ENVIRONMENTS -o json
dtmgd get problems --env "prod;staging" -o json
Works with all get, describe, and query commands.
Pagination
All list commands automatically follow nextPageKey to fetch complete results.
Use --limit to cap to a single page, or --max-pages to limit page count.
Watch Mode
Monitor resources in real-time:
dtmgd get problems --status OPEN --watch
dtmgd get events --from now-1h --watch --watch-interval 10s
Column Filtering
Show only specific columns in table output:
dtmgd get problems --columns "PROBLEM-ID,TITLE,STATUS"
dtmgd get entities --selector 'type(HOST)' --columns "ENTITY-ID,DISPLAY-NAME"
Context Management
dtmgd ctx
dtmgd config get-contexts
dtmgd ctx current
dtmgd ctx <context-name>
dtmgd config set-context prod \
--host https://managed.company.com \
--env-id abc12345 \
--token-ref prod-token
dtmgd config set-credentials prod-token --token <api-token>
dtmgd ctx delete <name>
Proxy support: add http-proxy and/or https-proxy to the context in the config file for environments behind corporate proxies.
Problems
dtmgd get problems --status OPEN
dtmgd get problems --status OPEN --env ALL_ENVIRONMENTS
dtmgd get problems --from now-2h --to now
dtmgd get problems --impact SERVICE --limit 20
dtmgd get problems --entity 'type(SERVICE),entityName.contains("checkout")'
dtmgd get problems --selector 'managementZones("bookstore")' --from now-7d --limit 5 --sort "-startTime"
dtmgd get problems --status OPEN --selector 'managementZones("bookstore")' --from now-7d
dtmgd get problems --status OPEN --impact SERVICE --selector 'managementZones("bookstore")' --from now-7d
dtmgd get problems --sort "+status"
dtmgd get problems --sort "-startTime"
dtmgd describe problem <uuid> -o json
Important: describe problem requires the internal UUID (e.g. 8a3f1b2c-...),
not the short display ID like P-12345. Some UUIDs are negative integers — pass
them after -- to avoid flag-parsing errors:
dtmgd describe problem -- -6546711275898328738_1776193140000V2
Entities
dtmgd get entity-types
dtmgd get entities --selector 'type(SERVICE)'
dtmgd get entities --selector 'type(HOST),healthState("HEALTHY")'
dtmgd get entities --selector 'type(SERVICE),entityName.contains("payment")'
dtmgd get entities --selector 'type(SERVICE),tag("env:production")'
dtmgd get entities --selector 'type(HOST)' --mz 'mzName("Production")'
dtmgd describe entity <entity-id> -o json
dtmgd describe entity-type SERVICE -o json
dtmgd describe entity-relations <entity-id> -o json
Events
dtmgd get events --from now-1h --to now
dtmgd get events --from now-6h --type CUSTOM_DEPLOYMENT
dtmgd get events --from now-24h --entity 'entityId("SERVICE-123ABC")'
dtmgd describe event <event-id> -o json
Metrics
dtmgd get metrics --search response.time
dtmgd get metrics --search cpu --entity 'type(HOST)'
dtmgd describe metric builtin:service.response.time -o json
dtmgd query metrics --metric builtin:service.response.time --from now-1h --to now
dtmgd query metrics --metric builtin:host.cpu.usage --from now-24h --resolution 1h
dtmgd query metrics \
--metric builtin:host.mem.usage \
--from now-6h \
--entity 'type(HOST),entityName.contains("web")' \
--resolution 30m
dtmgd query metrics \
--metric 'builtin:service.requestCount.server:splitBy("dt.entity.service"):sum:names' \
--entity 'type(SERVICE),tag("[Environment]BookStore")' \
--from now-1h --resolution Inf
dtmgd query metrics \
--metric 'builtin:service.requestCount.server:splitBy("dt.entity.service"):sum:names' \
--entity 'type(SERVICE),tag("[Environment]BookStore")' \
--from now-1h --resolution Inf
dtmgd query metrics \
--metric 'builtin:service.errors.server.count:splitBy("dt.entity.service"):sum:names' \
--entity 'type(SERVICE),tag("[Environment]BookStore")' \
--from now-1h --resolution Inf
dtmgd query metrics \
--metric 'builtin:service.response.time:splitBy("dt.entity.service"):avg:names' \
--entity 'type(SERVICE),tag("[Environment]BookStore")' \
--from now-1h --resolution Inf
Logs
dtmgd query logs --query "error" --from now-1h --to now
dtmgd query logs --query "timeout" --from now-30m --limit 50
dtmgd query logs --query "OutOfMemoryError" --from now-6h --sort -timestamp
dtmgd query logs --query "error" --from now-1h --entity 'type(PROCESS_GROUP),tag("[Environment]BookStore")'
dtmgd query log-counts --entity 'type(SERVICE),tag("[Environment]BookStore")' --from now-1h
dtmgd query log-counts --entity 'type(SERVICE),tag("[Environment]BookStore")' --from now-30m --to now
SLOs
dtmgd get slos
dtmgd get slos --enabled false
dtmgd get slos --evaluate
dtmgd get slos --selector 'managementZone("bookstore")' --evaluate
dtmgd get slos --selector 'text("OrderController")' --evaluate
dtmgd get slos --selector 'healthState("UNHEALTHY")' --evaluate
dtmgd describe slo <slo-id>
dtmgd describe slo <slo-id> --timeframe CURRENT
dtmgd describe slo <slo-id> --from now-2w --to now --timeframe GTF
Security Problems (CVE Vulnerabilities)
dtmgd get security-problems
dtmgd get security-problems --risk CRITICAL
dtmgd get security-problems --status OPEN --limit 50
dtmgd get security-problems --status OPEN --selector 'managementZones("bookstore")'
dtmgd get security-problems --status OPEN --selector 'managementZones("bookstore")' --limit 5
dtmgd get security-problems --status OPEN --risk CRITICAL --selector 'managementZones("bookstore")'
dtmgd describe security-problem S-42 --env prod -o json
Typical Investigation Workflow
dtmgd get environments
dtmgd get problems --status OPEN -o json
dtmgd get problems --status OPEN --env ALL_ENVIRONMENTS -o json
dtmgd describe problem <uuid> -o json
dtmgd get entities --selector 'type(SERVICE),entityName.contains("affected-service")'
dtmgd query metrics \
--metric builtin:service.response.time \
--from now-2h \
--entity 'entityId("SERVICE-XXXX")' \
--resolution 5m
dtmgd query logs --query "exception" --from now-2h --to now --limit 100
Time Format Reference
| Format | Example |
|---|
| Relative | now-1h, now-24h, now-7d, now-30m |
| ISO 8601 | 2024-01-01T10:00:00Z |
| Unix ms | 1640995200000 |
Gotchas
describe problem requires the UUID (PROBLEM-ID column), not the display ID (P-XXXXX).
- Problem UUIDs can be negative integers (e.g.
-6546711275898328738_1776193140000V2). Always pass them after -- to prevent the leading - being parsed as a flag: dtmgd describe problem -- -6546711275898328738_V2
get events requires --from; it won't default like get problems does.
query logs uses plain text search only — no content:, status:, or loglevel: structured syntax (LQL structured queries are unsupported on DT Managed Classic).
query log-counts counts log levels using full-text matching; accurate for Spring Boot/Java logs, may under-count WARN if framework uses "WARNING".
query log-counts internally converts type(SERVICE) entity selectors to type(PROCESS_GROUP) because DT Managed Classic attributes logs to process groups, not services. Services that log at ERROR-only level (e.g., BookStore prod profile) will show 0 INFO and 0 WARN — this is correct behavior, not a bug.
query logs --entity also requires type(PROCESS_GROUP) on DT Managed Classic (not type(SERVICE)). Using a SERVICE selector returns 0 results even though the API accepts the parameter.
- The logs aggregate endpoint's
entitySelector param is hidden=true on DT Managed Classic and does not actually filter results. query log-counts works around this by fetching entities first, then filtering aggregate results client-side.
- Entity selectors must specify exactly one entity type per query.
- Log search on Managed clusters does not support structured query syntax.
--limit caps results to a single page. Without it, all pages are fetched automatically.
- Multi-env results are keyed by context name:
{"prod": {...}, "staging": {...}}.
- Agent mode is auto-detected; use
--no-agent to get plain output in AI environments.
Feature Parity with Dynatrace Managed MCP Server
| MCP Tool | dtmgd command |
|---|
get_environments_info | dtmgd get environments |
list_available_metrics | dtmgd get metrics [--search <text>] |
get_metric_details | dtmgd describe metric <id> |
query_metrics_data | dtmgd query metrics --metric <id> --from <t> --to <t> |
query_logs | dtmgd query logs --query <text> --from <t> --to <t> [--entity <sel>] |
aggregate_logs | dtmgd query log-counts --entity <sel> --from <t> --to <t> |
list_events | dtmgd get events --from <t> |
get_event_details | dtmgd describe event <id> |
list_entity_types | dtmgd get entity-types |
get_entity_type_details | dtmgd describe entity-type <type> |
discover_entities | dtmgd get entities --selector <sel> |
get_entity_details | dtmgd describe entity <id> |
get_entity_relationships | dtmgd describe entity-relations <id> |
list_problems | dtmgd get problems |
get_problem_details | dtmgd describe problem <uuid> |
list_security_problems | dtmgd get security-problems |
get_security_problem_details | dtmgd describe security-problem <id> |
list_slos | dtmgd get slos |
get_slo_details | dtmgd describe slo <id> |