使用 AWS re:Post 即表示您同意 AWS re:Post 使用條款

Can I use Cloudwatch Metrics Insights to provide information about missing data in the included metrics?

0

I have systems that push a custom metric to CloudWatch metrics every 5 minutes. The metric values can be 1 (healthy), 0 (unhealthy), or missing (unhealthy - occurs if the system has crashed or gone off the network and can't report metrics). I'm looking to create a Metric Insights query and from there an Alarm that will alert me if any of these systems are unhealthy. I'm using this query:

SELECT MIN(Status) FROM SCHEMA("MyNamespace", MyDimension)

When I setup the Alarm, I selected "Treat Missing Data as Bad" which would work if I only had a single metric. But with multiple metrics it appears that if I have any systems healthy, the MIN(Status) will always return 1 and I do not detect that one of my systems has gone off the network.

Is there any way to use Metric Insights to return information about missing data for any of the underlying metrics in the query?

已提問 7 個月前檢視次數 259 次
1 個回答
5

Hi Bruce, look at my solution it will be helpful for your query.

It sounds like you need a way to detect missing data for any of the underlying metrics in your query. But Metric Insights doesn't directly support querying for missing data across multiple metrics in the same way as treating missing data as bad for individual metrics.

However, you can still achieve this by modifying your approach slightly. Instead of using MIN(Status), you can use the IF function to check if any of the systems are unhealthy or have missing data.

Here's how you can modify your query:

SELECT IF(COUNT(Status) = COUNT(*), 1, 0) AS Overall_Status FROM SCHEMA("MyNamespace", MyDimension)

This query will return 1 if all systems are healthy (meaning the count of reported statuses is equal to the count of systems), and 0 otherwise.

Then, when setting up the alarm, you can treat missing data as bad. This will ensure that if any system has missing data, the overall status will be considered as unhealthy, triggering the alarm.

專家
已回答 7 個月前
profile picture
專家
已審閱 5 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南