我无法通过此命令获取指标数据。
aws cloudwatch get-metric-data --metric-data-queries jsonfile.json \
--start-time 2019-02-01T10:40:0000 --end-time 2019-02-27T14:12:0000 将显示以下错误。
Error parsing parameter '--metric-data-queries': Expected: '=', received: 'EOF' for input:jsonfile.json
在这里,jsonfile.json包含我的查询,定义如下。
[
{
"Id": "MyRequest",
"MetricStat": {
"Metric": {
"Namespace": "AWS/EBS",
"MetricName": "VolumeReadBytes",
"Dimensions": [
{
"Name": "VolumeId",
"Value": "vol-******420********"
}
]
},
"Period": "3600",
"Stat": "Average",
"Unit": "Bytes"
},
"Label": "myRequestLabel",
"ReturnData": "true"
}
]发布于 2019-03-08 14:51:06
我认为你需要运行的是;
aws cloudwatch get-metric-data --cli-input-json file://jsonfile.json您的jsonfile.json的内容需要如下;
{
"MetricDataQueries": [
{
"Id": "myRequest",
"MetricStat": {
"Metric": {
"Namespace": "AWS/EBS",
"MetricName": "VolumeReadBytes",
"Dimensions": [
{
"Name": "VolumeId",
"Value": "vol-******420********"
}
]
},
"Period": 3600,
"Stat": "Average",
"Unit": "Bytes"
},
"Label": "myRequestLabel",
"ReturnData": true
}
],
"StartTime": "2019-02-01T10:40:0000",
"EndTime": "2019-02-27T14:12:0000"
}发布于 2021-09-12 10:39:42
如果您更喜欢bash脚本:
#!/bin/bash
start_time=$(date -d "24 hours ago" '+%Y-%m-%dT%H:%M:%S')
now=$(/usr/local/bin/date '+%Y-%m-%dT%H:%M:%S')
aws --output json cloudwatch get-metric-statistics --namespace AWS/NetworkELB \
--metric-name ActiveFlowCount --statistics Sum --period 3600 \
--dimensions Name=LoadBalancer,Value=net/YourHash1/YourHash2 \
--start-time $start_time --end-time $nowhttps://stackoverflow.com/questions/55057498
复制相似问题