gpt4 book ai didi

amazon-web-services - AWS CLI 获取指标统计

转载 作者:行者123 更新时间:2023-12-04 03:19:55 25 4
gpt4 key购买 nike

我正在尝试从我的 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"
}

但这不应该在 1 分钟内返回带时间戳的数据点吗?

最佳答案

无法从 Amazon CloudWatch 检索实际数据点

相反,CloudWatch 提供一段时间内的聚合指标(例如 Average、SampleCount、Sum)。

来自CloudWatch documentation :

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 应该在给定时间段内返回多个值。

我接受了你的命令并针对我的一个实例运行了它。我发现,通过扩展时间范围,我可以获得多个返回值:

{
"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 . (额外收费。)

关于amazon-web-services - AWS CLI 获取指标统计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39029743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com