20

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.

chrisrhyno2003
  • 3,906
  • 8
  • 53
  • 102
  • Have you confirmed that you see metrics based on that search expression? – Javier Diaz Apr 07 '19 at 18:58
  • @JavierDiaz: The Cloudwatch console shows me graphs as a result of the search expression, but it doesn't show them as individual metrics, which I suppose is the problem – chrisrhyno2003 Apr 08 '19 at 15:18
  • 4
    Indeed this does not work in Cloudwatch, but just one clarification: the `METRICS()` expression does not return math expressions so the `AVG(METRICS())` returns nothing. If you do `AVG(SEARCH('{AW......e', 300))` you should get one metric that theoretically could work with alarms - but currently unfortunately it seems not to work.. – Chananel P Jul 04 '19 at 11:56
  • Is this the still current state of things? Is it possible to set an alarm on some aggregate of a custom dimension (which could be done with this Search function alarm)? – Jared Dec 12 '19 at 21:22

2 Answers2

24

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

srodriguez
  • 1,937
  • 2
  • 24
  • 42
  • 3
    It would be nice to include a reference to the official documentation stating this, but I wasn't able to find one myself. – dskrvk Apr 21 '21 at 16:48
2

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."