0

Following is my payload

response = cloudwatch.get_metric_statistics(
    Namespace='AWS/S3',
    Dimensions=[
        {
            'Name': 'BucketName',
            'Value': 'foo-bar'
        },
        {
            'Name': 'StorageType',
            'Value': 'AllStorageTypes'
        }
    ],
    MetricName='BytesUploaded',
    StartTime=datetime(2021, 3, 11),
    EndTime=datetime(2021, 3, 14),
    Period=86400,
    Statistics=[
        'Maximum', 'Average'
    ]
)

and this is the response

{'Label': 'BytesUploaded', 'Datapoints': [], 'ResponseMetadata': {'RequestId': '1c6b02e9-9a8f-48e9-a2fd-1e21fd31a096', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '1c6b02e9-9a8f-48e9-a2fd-1e21fd31a096', 'content-type': 'text/xml', 'content-length': '336', 'date': 'Tue, 16 Mar 2021 05:51:05 GMT'}, 'RetryAttempts': 0}}

From AWS Console, I'm able to see datapoints for the same timestamp. I tried increasing the timeframe but it still gibes the same result

Can some help me please? thanksenter image description here

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Neo
  • 49
  • 12
  • Got it..! I used the AWS CLI command provided here https://stackoverflow.com/a/43645974/412129 – Neo Mar 19 '21 at 17:49

1 Answers1

0

First, If period variable is a refresh period maybe you should need to reduce. When I checked out to example, I saw period is 300.

Second, try to change endTime like:

from datetime import datetime
from datetime import timedelta

EndTime = datetime.utcnow(),
  • Thanks @Yunus I have tried those options earlier as well. It didn't help. I'm even wondering if there is a different method to use than get_metric_statistics() – Neo Mar 16 '21 at 06:39