aws_metrics_query
Query AWS CloudWatch metrics across multiple services with a single request, using metric math expressions and auto-picked periods to stay within response limits.
Instructions
Query CloudWatch metrics via GetMetricData (the modern multi-metric / expression-capable API, not the legacy get-metric-statistics). Pass queries as a flat array of {id, namespace, metricName, dimensions?, statistic?, period?, expression?, label?}; the tool shapes them into MetricDataQueries for you. startTime/endTime accept ISO 8601 or relative shorthand ('15m', '1h', '1d', '1w'); endTime defaults to 'now'. Period is auto-picked from the time range when omitted (60s for <=3h, 300s for <=24h, 900s for <=15d, 3600s otherwise) to stay under CloudWatch's ~100,800-datapoint response cap. Returns {series: [{id, label?, timestamps, values, statusCode?}], messages?, periodSeconds, profile, region, nextToken, hasMore}. When CloudWatch truncates a large response, hasMore is true and nextToken carries the resume cursor -- call again with nextToken set to fetch the next page (rare for typical agent queries that stay within the per-request cap). Use for 'show me the CPU on this instance for the last hour', 'sum lambda invocations across these 3 functions', or expression-based 'p99 latency divided by average latency' lookups.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| queries | Yes | 1-100 queries. Each is either a metric-stat (namespace + metricName) or an expression. | |
| startTime | No | ISO 8601 timestamp or relative shorthand ('15m', '1h', '1d', '1w'). Default '1h' (one hour ago). | |
| endTime | No | ISO 8601 timestamp or relative shorthand. Default 'now'. | |
| scanBy | No | Sort order for returned datapoints. Default 'TimestampDescending' (matches CloudWatch's default). | |
| maxDataPoints | No | Soft cap on returned datapoints across all queries. CloudWatch's hard cap is ~100,800; lower this to keep response sizes manageable. Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention. | |
| nextToken | No | Resume cursor from a previous call's `nextToken`. Omit for the first page. Forwarded as CloudWatch's NextToken; only meaningful when a prior call returned `hasMore: true`. | |
| profile | No | Override session profile for this call. | |
| region | No | Override session region for this call. | |
| timeoutMs | No | Timeout in milliseconds. Default 60000 (60s). |