Python列出原始Cloudwatch度量值

2024-09-28 18:49:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我将抛出boto3AWS的文档。并且找不到从我的自定义度量中获取原始值的简单信息

例如,我正试图在特定网站路径的访问权限上记录用户id。但从文档中,我只能访问聚合值。这意味着这是不可能的。这个静态变量是SampleCount'|'Average'|'Sum'|'Minimum'|'Maximum。这意味着我的用户id的特殊情况没有意义

UPD

简单地说,不支持从Cloudwatch获取原始值


Tags: 用户文档路径信息id权限度量网站
2条回答

CloudWatch不存储使用PutMetricData发布的原始值,它只存储聚合。您可以获得的最小粒度为1秒,最晚为3小时

如果您需要访问原始值,可以使用嵌入度量格式的CloudWatch日志来发布度量:https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format.html

这样,CloudWatch日志将创建您的自定义指标,而这些指标仍然只有聚合。您可以将其用于报警和仪表板

但是,您还可以查看原始的CloudWatch日志条目,查看发布的内容

您引用的统计信息是使用get_metric_statistics获得的。但是,要获得实际数据点,您应该查看get_metric_data

You can use the GetMetricData API to retrieve as many as 500 different metrics in a single request, with a total of as many as 100,800 data points.

但应该注意的是,数据点越老,分辨率越低。AWS不存储所有点。只有“新”数据将以原始分辨率存储

Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes.

聚合更新

也来自docs

Although you can publish data points with time stamps as granular as one-thousandth of a second, CloudWatch aggregates the data to a minimum granularity of 1 second.

相关问题 更多 >