如何删除 AWS CloudWatch 度量?

我正在让 AmazonWebServicesDynamoDB 中的一个服务退役。我们为 DyDB 表提供了各种指标和警报。我能够使用“ AWS Cloudwatch delete-alarms —— Alarm-name...”来删除警报,但是我没有看到任何删除指标的 AWS CLI 命令。

我知道指标保存数据2周。有没有可能,当没有更多的数据存储在里面的时候,这些指标会在2周内自动消失?很不幸,我没有看到任何文件证明这一点。

58484 次浏览

You're correct: there is no API to delete AWS Cloudwatch Metrics. Just wait two weeks after your last metric has been pushed. It will disappear automatically.

Since November 1, 2016, CloudWatch has extended the retention of metrics (both custom and AWS NameSpace) from previous 14 days to 15 months.

But the CW console limits the search of metrics to 2 weeks after a metric is last ingested (which means if there is a metric in which no datapoints has been pushed for past 14 days then the CW console will not display it but you can still get it using the cli get-metric-statistics or by tweaking the console url to refer the correct resource name and start and end time older than 14 days).

And there is no api to delete the metrics. https://aws.amazon.com/cloudwatch/faqs/

In support of the above, this is still an issue unfortunately. To read more on the AWS forum, please see: https://forums.aws.amazon.com/message.jspa?messageID=281904

https://aws.amazon.com/cloudwatch/faqs/

Amazon CloudWatch FAQs

[…]

Q: What is the retention period of all metrics?

CloudWatch retains metric data as follows:

  • Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution custom metrics.
  • Data points with a period of 60 seconds (1 minute) are available for 15 days
  • Data points with a period of 300 seconds (5 minute) are available for 63 days
  • Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months)
  • Data points that are initially published with a shorter period are aggregated together for long-term storage.

[…]

Q: Can I delete any metrics?

CloudWatch does not support metric deletion. Metrics expire based on the retention schedules described above.