cloudwatch命令获取度量数据

时间:2019-03-08 05:57:05

标签: amazon-web-services amazon-ec2 amazon-cloudwatch amazon-ebs

我无法通过此命令获取指标数据。

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"
    }
]

1 个答案:

答案 0 :(得分:0)

我认为您需要运行的是

    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"
    }