Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudwatch Alarm across all dimensions based on metric name for custom metrics

We are publishing custom Cloudwatch metrics from our service and want to set up alarms if the value for a metric name breaches a threshold for any dimension. Here are the metrics we are publishing:

  1. Namespace=SameName, MetricName=Fault, Dimensions=[Operation=A, Program=ServiceName]
  2. Namespace=SameName, MetricName=Fault, Dimensions=[Operation=B, Program=ServiceName]
  3. Namespace=SameName, MetricName=Fault, Dimensions=[Operation=C, Program=ServiceName]

We want to set up an alarm so that a Fault across any dimension puts it into the Alarm state.

As you can see, the value for dimension Operation is different. Currently, we only have these 3 operations, so I understand we can use metric math to set up this alarm. But I am sure we will get to a point where this will keep growing.

I am able to use SEARCH expression + aggregate across search expression to generate a graph for it, but it does not let me create an alarm saying The expression for an alarm must include at least one metric.

Is there any other way I can achieve this?

like image 634
user2684198 Avatar asked Feb 11 '20 01:02

user2684198


People also ask

What is a separate metric in Amazon CloudWatch?

Amazon CloudWatch treats each unique combination of dimensions as a separate metric. For example, each call to mon-put-data in the following figure creates a separate metric because each call uses a different set of dimensions.

How do I create a custom metric in CloudWatch?

Create an alarm for your custom metric. On the CloudWatch console, choose Alarms and then choose Create Alarm. Choose Select metric and enter the name of the metric that you created earlier into the search box. Choose the Graphed metrics tab and configure the options according to your requirements.

Why can't CloudWatch aggregate across multiple dimensions?

However, CloudWatch is NOT able to aggregate across these dimensions, as it doesn't know the groups of these dimensions. Basically: Amazon CloudWatch treats each unique combination of dimensions as a separate metric.

How do I create a graphed alarm in CloudWatch?

On the CloudWatch console, choose Alarms and then choose Create Alarm. Choose Select metric and enter the name of the metric that you created earlier into the search box. Choose the Graphed metrics tab and configure the options according to your requirements. Under Conditions, choose Anomaly detection instead of Static thresholds.


2 Answers

Alarming directly on SEARCH is not supported yet. You would have to create a metric math expression where you list all 3 metrics, then create an expression that takes the max of the 3, like MAX(METRICS()). Make sure only the expression is marked as visible so that there is only 1 line on the graph.

like image 142
Dejan Peretin Avatar answered Oct 04 '22 06:10

Dejan Peretin


As stated by Dejan, alarming on search isn't supported yet on Cloudwatch. Another limitation is that you can only add up to 10 metrics to a metric math expression, which you can overcome with the new composite alarms.

If you would consider using a 3rd party service, you can try DataDog.

With DataDog you can import your cloudwatch metrics and set up multi-alarms which follow (and automatically discover) all tags under a specific metric.

There might be other services that offer this kind of feature, but I specifically have experience with this tool.

like image 37
Doody P Avatar answered Oct 04 '22 07:10

Doody P