Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a CloudWatch alarm based on a search expression

I'm attempting to the do the following:

I have a DynamoDB global table which publishes the ReplicationLatency metric. I want to create an alarm on the aggregate of the ReplicationLatency metric published for each region.

The DDB table replicas exist in us-east-1, us-west-2 and us-west-1. In defining the CW alarm for each receiving region, I was under the assumption that I could a search expression. For example, here's the expression I see in the CloudWatch console.

SEARCH('{AWS/DynamoDB,ReceivingRegion,TableName} MetricName="ReplicationLatency"', 'Average', 300)

I'd like to create a metric math alarm which is the avg of the metrics of the above search result. I was attempting to create a metric math expression of the format:

AVG(METRICS())

I then get the following error - The expression for an alarm must include at least one metric. Has anybody attempted to create an alarm from a search expression before? If yes, could you shed some light on how it can be done?

The only other way I can think of solving this problem is to enumerate/add the ReplicationLatency metric for each receiving region and then create a metric math expression out of that. That's seems to completely defeat the purpose of having a search expression and creating an alarm from all those metrics.

like image 725
chrisrhyno2003 Avatar asked Apr 05 '19 21:04

chrisrhyno2003


People also ask

How do I trigger AWS CloudWatch alarm?

On the Manage CloudWatch alarms detail page, under Add or edit alarm, select Create an alarm. For Alarm notification, choose whether to turn the toggle on or off to configure Amazon Simple Notification Service (Amazon SNS) notifications. Enter an existing Amazon SNS topic or enter a name to create a new topic.

How do I customize my CloudWatch alarm message?

Open the CloudWatch console, choose Rules, and then choose Create rule. For Event source, choose Event pattern, and then choose Custom event pattern. To match on specific alarm state transitions, add the ARNs of your alarms.


2 Answers

You cannot do alarms on search expressions at the moment.

You will have to add manually all the metrics you want to alarm on and then use the math function you specified above.

edit: official documentation link

like image 51
srodriguez Avatar answered Oct 19 '22 08:10

srodriguez


Here is the link to official documentation: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Create-alarm-on-metric-math-expression.html

"You can't create an alarm based on the SEARCH expression. This is because search expressions return multiple time series, and an alarm based on a math expression can watch only one time series."

like image 2
legendryrdx Avatar answered Oct 19 '22 10:10

legendryrdx