AWS CLI 获取指标统计
AWS CLI get-metric-statistics
我正在尝试从我的 ec2 实例请求 CPUUtilization
,然后 this Command Reference 我正在使用以下命令
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"
}
但这 return 我的数据点不应该在 1 分钟内带有时间戳吗?
无法从 Amazon CloudWatch 检索实际数据点。
相反,CloudWatch 提供一段时间内的汇总指标(例如平均值、样本计数、总和)。
Amazon CloudWatch aggregates statistics according to the period length that you specify in calls to GetMetricStatistics
. You can publish as many data points as you want with the same or similar time stamps. CloudWatch aggregates them by period length when you get statistics about those data points with GetMetricStatistics
.
但是,正如您所指出的,CloudWatch 应该在给定时间段内返回多个值。
我接受了你的命令,运行它对付了我的一个实例。我发现,通过延长时间 运行ge,我可以获得多个返回值:
{
"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 分钟为间隔获取指标,您需要 Enable Detailed Monitoring。 (额外收费。)
我正在尝试从我的 ec2 实例请求 CPUUtilization
,然后 this Command Reference 我正在使用以下命令
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"
}
但这 return 我的数据点不应该在 1 分钟内带有时间戳吗?
无法从 Amazon CloudWatch 检索实际数据点。
相反,CloudWatch 提供一段时间内的汇总指标(例如平均值、样本计数、总和)。
Amazon CloudWatch aggregates statistics according to the period length that you specify in calls to
GetMetricStatistics
. You can publish as many data points as you want with the same or similar time stamps. CloudWatch aggregates them by period length when you get statistics about those data points withGetMetricStatistics
.
但是,正如您所指出的,CloudWatch 应该在给定时间段内返回多个值。
我接受了你的命令,运行它对付了我的一个实例。我发现,通过延长时间 运行ge,我可以获得多个返回值:
{
"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 分钟为间隔获取指标,您需要 Enable Detailed Monitoring。 (额外收费。)