Composite Alarms are a useful feature to reduce noise in your monitoring system. Learn how to create one in this step by step tutorial.
Composite Alarms allow us to create an alarm that will fire whenever underlying alarms fire. They are very useful in reducing the number of alarms that may fire in an application. They can also add as a single identifier of health across an entire system. The key though is to only trigger a notification on the top level aggregate alarm, or else you’re just going to get bombarded with alarm notifications.
For example, we can create a composite alarm that combines all the metrics of an entire service into one composite alarm. If the state of this alarm is OK, we can assume the system is in a healthy state. We’ll configure it to only send notifications if the aggregate alarm fires.
In this walkthrough, I’m going to show you how to create a composite alarm that will combine two separate alarms:
- Lambda Error Alarm that fires when errors are 5 or more in a 5 minute window
- Lambda Latency Alarm that fires when average latency exceeds 100ms in a 5 minute window.
If you don’t know how to create a Cloudwatch Alarm, check out my other tutorial video here.
This should give you an example to work off of to create more complex alarms in your application.
So lets get started…
The only pre-requisite for this walkthrough is that you have two or more alarms already created and available in your cloudwatch account. I’ve gone ahead and created the two alarms listed above as a starting step for this walkthrough. My Cloudwatch alarm page looks like the following:
Creating Our Cloudwatch Composite Alarm
To create our composite alarm, navigate to the Alarms section of the AWS console. After finding your alarms in the dropdown list (tip: you can type in the search box to filter by name), select the checkboxes beside each of the alarms you’d like to include. Afterwards, select Create Composite Alarm in the top right part of your screen, as seen below.
In the next screen, we need to set our Conditions for the alarm. This is basic AND/OR logic. In our case, we want to fire our composite alarm if EITHER of the underlying alarms are breached. Therefore, we use the basic OR conditions as seen below.
Note that there’s a bunch of great examples of more complex alarms being configured on the aws documentation.
Go ahead and click on Next to proceed to the Actions step.
In the Actions step, this is our normal actions page when we’re creating any old Cloudwatch alarm. Go ahead and create a new or select an existing SNS topic to configure your notification mechanism and click Next.
On the following screen, simply give your alarm a name and click Next to see the confirmation page.
After clicking through all the confirmation pages, you’ll see your brand new composite alarm as seen below.
After deliberately making my Lambda function error out a few times, you can see that my LambdaErrorsAlarm is currently in Alarm, and so is our new Composite Alarm as seen below.
And that’s it! You’re now prepared to go ahead and create some more sophisticated alarms using this cool new feature. I hope you enjoyed the tutorial and let me know if you have comments or questions down below!