prometheus / cloudwatch_exporter

Metrics exporter for Amazon AWS CloudWatch
Apache License 2.0
906 stars 325 forks source link

fix how the metricRequestedForBilling is counted to use queries.size() #741

Closed emmanuelperotto closed 2 weeks ago

emmanuelperotto commented 2 months ago

This change fixes how the exporter counts the metrics that will be billed for the GetMetricData request.

The YACE already fixed this in their implementation as seen here: https://github.com/nerdswords/yet-another-cloudwatch-exporter/blob/master/pkg/clients/cloudwatch/v2/client.go#L117

image

EXAMPLE

MetricDataQueries=[
        {
            'Id': 'foo',
            'MetricStat': {
                'Metric': {
                    'Namespace': 'AWS/DynamoDB',
                    'MetricName': 'ConsumedWriteCapacityUnits',
                    'Dimensions': [
                        {'Name': 'TableName',
                         'Value': 'one-table'}
                    ]
                },
                'Period': 300,   # 5 minutes
                'Stat': 'Sum',
                'Unit': 'Count'
            },
            'ReturnData': True,
        },
        {
            'Id': 'bar',
            'MetricStat': {
                'Metric': {
                    'Namespace': 'AWS/DynamoDB',
                    'MetricName': 'ConsumedWriteCapacityUnits',
                    'Dimensions': [
                        {'Name': 'TableName',
                         'Value': 'another-table'}
                    ]
                },
                'Period': 300,   # 5 minutes
                'Stat': 'Sum',
                'Unit': 'Count'
            },
            'ReturnData': True,
        }
    ]

For this scenario YACE would increase 2 to the counter metric while this exporter would increase by 1 only

emmanuelperotto commented 2 weeks ago

@matthiasr feedbacks are welcome =)