1 Answer
- Newest
- Most votes
- Most comments
0
You can use* aws cloudwatch get-metric-data* which will allow you to pass an array of metric data queries. (Reference - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudwatch/get-metric-data.html)
A sample command will look like this -
COMMAND aws cloudwatch get-metric-data --cli-input-json file://input.json
INPUT FILE - input.json
{
"MetricDataQueries": [{
"Id": "cpuUtilization",
"MetricStat": {
"Metric": {
"Namespace": "AWS/EC2",
"MetricName": "CPUUtilization",
"Dimensions": [{
"Name": "InstanceId",
"Value": "i-000000"
}]
},
"Period": 60,
"Stat": "Average"
},
"ReturnData": true
},
{
"Id": "networkPacketsOut",
"MetricStat": {
"Metric": {
"Namespace": "AWS/EC2",
"MetricName": "NetworkPacketsOut",
"Dimensions": [{
"Name": "InstanceId",
"Value": "i-000000"
}]
},
"Period": 60,
"Stat": "Average"
},
"ReturnData": true
}
],
"StartTime": "2022-04-01T00:00:00",
"EndTime": "2022-04-30T00:00:00"
}
SAMPLE OUTPUT
{
"MetricDataResults": [{
"Id": "cpuUtilization",
"Label": "CPUUtilization",
"Timestamps": [
"2022-04-20T01:07:00+00:00",
"2022-04-20T01:02:00+00:00",
"2022-04-20T00:57:00+00:00"
],
"Values": [
0.09945355191256719,
0.13280540890988418,
0.13450128228466757
],
"StatusCode": "Complete"
},
{
"Id": "networkPacketsOut",
"Label": "NetworkPacketsOut",
"Timestamps": [
"2022-04-20T01:07:00+00:00",
"2022-04-20T01:02:00+00:00",
"2022-04-20T00:57:00+00:00"
],
"Values": [
82.4,
86.6,
82.2
],
"StatusCode": "Complete"
}
],
"Messages": []
}
answered 2 years ago
Relevant content
- asked 9 months ago
- Accepted Answerasked 7 months ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 months ago