问题描述
我正在尝试从我的ec2实例中请求CPUUtilization
,并遵循此命令参考我正在使用以下命令
I'm trying to request the CPUUtilization
from my ec2 instance and following this Command Reference i'm using the following command
aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2016-08-08T22:48:00 --end-time 2016-08-08T22:53:00 --period 60 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-myinstanceid
我的回答是:
{
"Datapoints": [
{
"Timestamp": "2016-08-08T22:51:00Z",
"Maximum": 0.17,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
但是这不应该在1分钟内返回带有时间戳的数据点吗?
but shouldn't this return me Data Points with Timestamp within 1 minute?
推荐答案
无法从Amazon CloudWatch检索实际数据点.
It is not possible to retrieve actual data points from Amazon CloudWatch.
相反,CloudWatch在一段时间内提供了汇总指标(例如,平均值,采样计数,总和).
Instead, CloudWatch provides aggregated metrics over a period of time (eg Average, SampleCount, Sum).
从 CloudWatch文档:
但是,正如您所指出的,CloudWatch应该在给定的时间段内返回多个值.
However, as you point out, CloudWatch should be returning multiple values over the given time period.
我接受了您的命令,并针对我的一个实例运行了它.我发现,通过扩展时间范围,我可以返回多个值:
I took your command and ran it against one of my Instances. I found that, by extending the time range, I could get multiple values returned:
{
"Datapoints": [
{
"Timestamp": "2016-08-08T22:52:00Z",
"Maximum": 0.0,
"Unit": "Percent"
},
{
"Timestamp": "2016-08-08T22:47:00Z",
"Maximum": 0.17,
"Unit": "Percent"
},
{
"Timestamp": "2016-08-08T22:42:00Z",
"Maximum": 0.16,
"Unit": "Percent"
},
{
"Timestamp": "2016-08-08T22:37:00Z",
"Maximum": 0.17,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
请注意,我的数据点仅每5分钟返回一次.这是因为对Amazon EC2实例的标准监视仅每5分钟捕获一次指标.要每隔1分钟获取一次指标,您需要启用详细监控. (需要支付额外费用.)
Notice that my data points were coming back only every 5 minutes. This is because standard monitoring of Amazon EC2 instances only captures metrics every 5 minutes. To obtain metrics at 1-minute intervals, you will need to Enable Detailed Monitoring. (Additional charges apply.)
这篇关于AWS CLI get-metric-statistics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!