i need to create a lambda function which has to fetch CPUUtilization of ec2 from cloudwatch and generate a csv report. When i tried fetching it using following code response is null,
import json
import boto3
import datetime
cw = boto3.client(service_name='cloudwatch',region_name = 'ap-south-1')
def lambda_handler(eeeee, context):
# TODO implement
response = cw.get_metric_statistics(
Namespace = 'AWS/EC2',
Period = 600,
StartTime = '2021-01-27T00:00:00Z',
EndTime = '2021-01-28T12:00:00Z',
MetricName = 'CPUUtilization',
Statistics=['Average'],
Dimensions = [
{
'Name': 'InstanceId',
'Value': 'i-0ae327'
}
]
)
But when i try in AWSCLI am recieving some datapoints,
{
"Namespace": "AWS/EC2",
"MetricName": "CPUUtilization",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-0ae327"
}
],
"StartTime": "2021-01-27T00:00:00",
"EndTime": "2021-01-28T12:00:00",
"Period": 600,
"Statistics": [
"Average"
]
}
What am i missing? Please help out..
question from:
https://stackoverflow.com/questions/65951223/response-is-null-when-trying-to-fetch-cpu-utilization-metric-from-cloudwatch-fro 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…