Search code examples
amazon-web-servicesamazon-cloudwatch

What is the purpose of StatisticValues field in PutMetricData?


What is the purpose of StatisticValues field in PutMetricData()?

From the PutMetricData() documentation it is not clear how to use StatisticValues.

From what I saw it seems like it is applicable only when retrieving the metrics, not when publishing the metric.


Solution

  • Interestingly, the put_metric_data() - Boto3 documentation shows it being used:

    response = client.put_metric_data(
        Namespace='string',
        MetricData=[
            {
                'MetricName': 'string',
                'Dimensions': [
                    {
                        'Name': 'string',
                        'Value': 'string'
                    },
                ],
                'Timestamp': datetime(2015, 1, 1),
                'Value': 123.0,
                'StatisticValues': {
                    'SampleCount': 123.0,
                    'Sum': 123.0,
                    'Minimum': 123.0,
                    'Maximum': 123.0
                },
                'Values': [
                    123.0,
                ],
                'Counts': [
                    123.0,
                ],
                'Unit': 'Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None',
                'StorageResolution': 123
            },
        ]
    )
    

    The documentation for StatisticValues says "The statistical values for the metric."

    I suspect that it is possible to send statistics rather than individual metrics, but I agree that I couldn't see anydocumentation about.