A collection of Python CLI utilities for interacting with the Dynatrace API — covering Grail DQL queries, EF2.0 extension health, OpenPipeline SDLC event ingestion, Management Zone coverage auditing, and Monaco configuration drift detection.
Built for use in real Dynatrace environments. All scripts use environment variables for credentials and are safe to commit to public repos.
| Script | Description |
|---|---|
dql_runner.py |
Execute parameterized DQL queries against the Grail API |
extension_health_checker.py |
Audit EF2.0 extension versions and monitoring config state |
openpipeline_event_pusher.py |
Push structured SDLC events (deploy, build, test) via BizEvents |
mz_coverage_reporter.py |
Identify entities not covered by any Management Zone |
monaco_auditor.py |
Detect drift between a Monaco project and the live environment |
# Clone and install dependencies
git clone https://github.com/EntropicSage/dynatrace-api-tools.git
cd dynatrace-api-tools
pip install -r requirements.txt
# Configure credentials
cp .env.example .env
# Edit .env with your environment URL and API token| Script | Required Scopes |
|---|---|
dql_runner.py |
storage:logs:read, storage:metrics:read, storage:bizevents:read |
extension_health_checker.py |
extensions.read |
openpipeline_event_pusher.py |
bizevents.ingest |
mz_coverage_reporter.py |
entities.read, settings.read |
monaco_auditor.py |
settings.read |
Execute any DQL query interactively or from a file. Handles Grail's async poll pattern automatically.
# Run a query inline
python scripts/dql_runner.py --query "fetch logs | filter loglevel == \"ERROR\" | limit 20"
# Run from a .dql file, output as CSV
python scripts/dql_runner.py --file queries/slow_traces.dql --format csv --output results.csv
# Output as JSON
python scripts/dql_runner.py --query "fetch dt.entity.service | limit 10" --format jsonAudit all installed EF2.0 extensions — version state, environment activation, and monitoring config counts.
# Check all extensions
python scripts/extension_health_checker.py
# Filter to custom extensions only
python scripts/extension_health_checker.py --filter "custom:"
# Check a single extension
python scripts/extension_health_checker.py --extension com.dynatrace.extension.cisco-ucs-redfish
# Export as JSON
python scripts/extension_health_checker.py --format json --output ext_health.jsonExample output:
┌──────────────────────────────────────┬───────────┬───────────┬─────────┬────────────┬─────────┬────────┐
│ Extension │ Installed │ Latest │ Outdated│ Env Active │ Configs │ Active │
├──────────────────────────────────────┼───────────┼───────────┼─────────┼────────────┼─────────┼────────┤
│ custom:cisco-ucs-redfish │ 1.2.1 │ 1.2.3 │ YES │ yes │ 4 │ 4 │
│ com.dynatrace.extension.snmp │ 2.1.0 │ 2.1.0 │ no │ yes │ 12 │ 11 │
└──────────────────────────────────────┴───────────┴───────────┴─────────┴────────────┴─────────┴────────┘
1 extension(s) running below latest version.
Push structured SDLC events into Dynatrace as BizEvents, compatible with OpenPipeline routing rules.
# Push a deployment event
python scripts/openpipeline_event_pusher.py deployment \
--service payment-api \
--version 2.3.1 \
--stage production \
--pipeline "azure-devops" \
--triggered-by "CI/CD" \
--status success
# Push a build event
python scripts/openpipeline_event_pusher.py build \
--service payment-api \
--version 2.3.1 \
--status success
# Push test results
python scripts/openpipeline_event_pusher.py test \
--service payment-api \
--version 2.3.1 \
--test-suite integration \
--passed 142 \
--failed 0
# Dry run (prints payload without sending)
python scripts/openpipeline_event_pusher.py deployment \
--service my-svc --version 1.0.0 --dry-run
# Push a pre-built event JSON file
python scripts/openpipeline_event_pusher.py from-file event.jsonEvents follow CloudEvents 1.0 spec with sdlc.* type prefixes for clean OpenPipeline rule targeting.
Find entities that aren't included in any Management Zone — useful for governance audits.
# Check all supported entity types
python scripts/mz_coverage_reporter.py
# Check only services
python scripts/mz_coverage_reporter.py --entity-type SERVICE
# Export uncovered hosts to JSON
python scripts/mz_coverage_reporter.py --entity-type HOST --format json --output uncovered_hosts.jsonSupported entity types: SERVICE, HOST, PROCESS_GROUP, APPLICATION, SYNTHETIC_TEST, CLOUD_APPLICATION, KUBERNETES_CLUSTER
Compare a local Monaco (Configuration as Code) project against the live Dynatrace environment and report configuration drift.
# Audit an entire Monaco project
python scripts/monaco_auditor.py --project ./monaco-project
# Audit a specific schema only
python scripts/monaco_auditor.py --project ./monaco-project --schema builtin:alerting.profile
# Export drift report as JSON
python scripts/monaco_auditor.py --project ./monaco-project --format json --output drift.jsonExample output:
┌──────────────────────────────────┬────────┬───────┬──────┬────────────────┬───────────────┐
│ Schema │ Status │ Local │ Live │ Only in Monaco │ Only in Live │
├──────────────────────────────────┼────────┼───────┼──────┼────────────────┼───────────────┤
│ builtin:alerting.profile │ OK │ 5 │ 5 │ none │ none │
│ builtin:management-zones │ DRIFT │ 8 │ 10 │ none │ legacy-zone-1 │
│ │ │ │ │ │ temp-mz-2023 │
└──────────────────────────────────┴────────┴───────┴──────┴────────────────┴───────────────┘
Summary: 1 schema(s) in sync, 1 schema(s) with drift
dynatrace-api-tools/
├── scripts/
│ ├── dql_runner.py
│ ├── extension_health_checker.py
│ ├── openpipeline_event_pusher.py
│ ├── mz_coverage_reporter.py
│ └── monaco_auditor.py
├── utils/
│ └── dt_client.py # Shared API client (auth, retry, rate limiting)
├── .env.example
├── requirements.txt
└── README.md
| Variable | Description |
|---|---|
DT_ENV_URL |
Your Dynatrace environment URL (e.g. https://abc12345.live.dynatrace.com) |
DT_API_TOKEN |
Dynatrace API token with required scopes (see table above) |
MIT