1 個回答
- 最新
- 最多得票
- 最多評論
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": []
}
已回答 2 年前
相關內容
- 已提問 6 個月前
- 已提問 6 個月前
- AWS 官方已更新 2 年前