CloudWatchClient.get_metric_data
rboto-cloudwatch==0.4.0 · Service index · Types
Model summary (excerpt): You can use the GetMetricData API to retrieve CloudWatch metric values. The operation can also include a CloudWatch Metrics Insights query, and one or more metric math functions. A GetMetricData operation that does not include a query can retrieve as many as 500 different metrics in a single request, with a total of as many as 100,800 data points. You can also optionally perform metric math...
Install and imports
from rboto import CloudWatchClient
from collections.abc import Sequence
from rboto_cloudwatch.types import (
GetMetricDataOutput,
LabelOptions,
MetricDataQuery,
ScanBy,
)
Signature
async def get_metric_data(
*,
metric_data_queries: Sequence[MetricDataQuery],
start_time: str,
end_time: str,
next_token: str | None = None,
scan_by: ScanBy | None = None,
max_datapoints: int | None = None,
label_options: LabelOptions | None = None,
) -> GetMetricDataOutput: ...
Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.
Arguments
| Argument | Required | Model notes (excerpt) |
|---|---|---|
metric_data_queries |
Yes | The metric queries to be returned. A single GetMetricData call can include as many as 500 MetricDataQuery structures. Each of these structures can specify either a metric to retrieve, a Metrics Insights query, or a math expression to perform on retrieved data. |
start_time |
Yes | The time stamp indicating the earliest data to be returned. The value specified is inclusive; results include data points with the specified time stamp. CloudWatch rounds the specified time stamp as follows: Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded down to 12:32:00. Start time between 15 and 63 days ago - Round down to the... |
end_time |
Yes | The time stamp indicating the latest data to be returned. The value specified is exclusive; results include data points up to the specified time stamp. For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as... |
next_token |
No | Include this value, if it was returned by the previous GetMetricData operation, to get the next set of data points. |
scan_by |
No | The order in which data points should be returned. TimestampDescending returns the newest data first and paginates when the MaxDatapoints limit is reached. TimestampAscending returns the oldest data first and paginates when the MaxDatapoints limit is reached. If you omit this parameter, the default of TimestampDescending is used. |
max_datapoints |
No | The maximum number of data points the request should return before paginating. If you omit this, the default of 100,800 is used. |
label_options |
No | This structure includes the Timezone parameter, which you can use to specify your time zone so that the labels of returned data display the correct time for your time zone. |
Output
GetMetricDataOutput.
Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.
| Field | Type | Presence | References |
|---|---|---|---|
metric_data_results |
list[MetricDataResultOutput] | None |
Always present | MetricDataResultOutput |
next_token |
str | None |
Always present | — |
messages |
list[MessageDataOutput] | None |
Always present | MessageDataOutput |
| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.
Related types
GetMetricDataOutput, LabelOptions, MetricDataQuery, ScanBy
Follow these links for nested inputs and outputs; recursive types link back to the same type page.
Pagination and streaming
client.paginators.get_metric_data(...) accepts the same arguments and returns AsyncIterator[GetMetricDataOutput]. Direct calls return one page. Pages preserve the Output representation above.
Input cursors: next_token. Page-size argument: max_datapoints.
No output stream.
Errors
Import from rboto_cloudwatch.exceptions:
Other service failures use the service base error; credential, transport and timeout failures use shared errors.