Pra*_*ila 7 amazon-ec2 amazon-ebs amazon-web-services amazon-cloudwatch
我无法通过此命令获取指标数据。
aws cloudwatch get-metric-data --metric-data-queries jsonfile.json \
--start-time 2019-02-01T10:40:0000 --end-time 2019-02-27T14:12:0000
Run Code Online (Sandbox Code Playgroud)
正在显示以下错误。
Error parsing parameter '--metric-data-queries': Expected: '=', received: 'EOF' for input:
Run Code Online (Sandbox Code Playgroud)
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"
}
]
Run Code Online (Sandbox Code Playgroud)
mar*_*ber 20
我认为你需要运行的是;
aws cloudwatch get-metric-data --cli-input-json file://jsonfile.json
Run Code Online (Sandbox Code Playgroud)
你的 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"
}
Run Code Online (Sandbox Code Playgroud)
AAb*_*er 6
如果您更喜欢 bash 脚本:
#!/bin/bash
start_time=$(date --utc -d "24 hours ago" '+%Y-%m-%dT%H:%M:%S')
now=$(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 $now
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8652 次 |
| 最近记录: |