Skip to content

CloudWatchClient.put_metric_data

rboto-cloudwatch==0.4.0 · Service index · Types

Model summary (excerpt): Publishes metric data to Amazon CloudWatch. CloudWatch associates the data with the specified metric. If the specified metric does not exist, CloudWatch creates the metric. When CloudWatch creates a metric, it can take up to fifteen minutes for the metric to appear in calls to ListMetrics . You can publish metrics with associated entity data (so that related telemetry can be found and viewed...

Install and imports

python -m pip install "rboto[cloudwatch]==0.4.0"
from rboto import CloudWatchClient
from collections.abc import Sequence
from rboto_cloudwatch.types import (
    EntityMetricData,
    MetricDatum,
)

Signature

async def put_metric_data(
    *,
    namespace: str,
    metric_data: Sequence[MetricDatum] | None = None,
    entity_metric_data: Sequence[EntityMetricData] | None = None,
    strict_entity_validation: bool | None = None,
) -> None: ...

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)
namespace Yes The namespace for the metric data. You can use ASCII characters for the namespace, except for control characters which are not supported. To avoid conflicts with Amazon Web Services service namespaces, you should not specify a namespace that begins with AWS/
metric_data No The data for the metrics. Use this parameter if your metrics do not contain associated entities. The array can include no more than 1000 metrics per call. The limit of metrics allowed, 1000, is the sum of both EntityMetricData and MetricData metrics.
entity_metric_data No Data for metrics that contain associated entity information. You can include up to two EntityMetricData objects, each of which can contain a single Entity and associated metrics. The limit of metrics allowed, 1000, is the sum of both EntityMetricData and MetricData metrics.
strict_entity_validation No Whether to accept valid metric data when an invalid entity is sent. When set to true : Any validation error (for entity or metric data) will fail the entire request, and no data will be ingested. The failed operation will return a 400 result with the error. When set to false : Validation errors in the entity will not associate the metric with the entity, but the metric data will still be...

Output

None.

| 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.

EntityMetricData, MetricDatum

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_cloudwatch.exceptions:

InternalServiceFaultError, InvalidParameterCombinationError, InvalidParameterValueError, MissingRequiredParameterError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Example

Complete, type-checked service example. Replace its placeholders and configure credentials before running it.

import asyncio

from rboto import CloudWatchClient


async def main() -> None:
    async with CloudWatchClient(region="eu-west-2") as client:
        await client.put_metric_data(
            namespace="MyApplication",
            metric_data=[{
                "metric_name": "ProcessedEvents",
                "value": 1.0,
                "unit": "Count",
                "dimensions": [{"name": "Environment", "value": "development"}],
            }],
        )
        async for page in client.paginators.describe_alarms(max_records=20):
            for alarm in page.metric_alarms or []:
                print(alarm.alarm_name, alarm.state_value)


if __name__ == "__main__":
    asyncio.run(main())

Service guide · Pinned model