Query Metrics
dynatrace_metrics_queryRun bounded DQL timeseries or Environment API v2 metric selector queries to retrieve Dynatrace metric data with filters, grouping, and time windows.
Instructions
Run a DQL timeseries or Environment API v2 metric selector within date bounds.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | DQL by fields, e.g. k8s.pod.name, k8s.namespace.name | |
| to | No | End: now or ISO-8601 | |
| from | No | Start: now-30m or ISO-8601 | |
| around | No | Pivot timestamp for a window | |
| filter | No | Optional DQL | filter ... | |
| metric | Yes | Metric id, e.g. dt.kubernetes.container.cpu_usage | |
| window | No | Half-window around pivot, e.g. 2m | |
| endDate | No | Calendar end YYYY-MM-DD (UTC day) | |
| startDate | No | Calendar start YYYY-MM-DD (UTC day) | |
| connection | No | Named connection from env (default, optional stage/prod aliases, or a DYNATRACE_CONNECTIONS key) | |
| useClassicApi | No | If true, GET /api/v2/metrics/query | |
| allowLongRange | No | Allow ranges longer than the default cap |