Composite Alarms in AWS Cloud: Advanced Notification System
Tags: aws, cloud, monitoring, devops
Published: 2024-03-28 20:34:10

Monitoring the state and performance of various resources is a crucial element in maintaining stability and efficiency within IT systems. One of the most powerful monitoring tools in **AWS cloud** is the **CloudWatch** service, which enables the collection and monitoring of **metrics and logs** from various AWS services and resources.

Within the CloudWatch service, there exists the capability to create "composite alarms," allowing the consolidation of multiple alarms into one logical expression. This enables the creation of more complex monitoring conditions, significantly enhancing the flexibility and capabilities of the monitoring system within AWS cloud.

{% embed https://www.youtube.com/watch?v=g23DEJiG8fk %}

### Consolidating Alarms into Composite Alarms

A composite alarm in AWS CloudWatch allows for the combination of alarms from other metrics or resources into one logical expression. This means that we can specify a condition that will be triggered when the conditions of all defined alarms within it are met. We can also apply different logical operators such as **AND, OR, or NOT**, providing us with a wide range of options for defining advanced monitoring rules.

### Operators Available for Use:

1. **AND**: This logical operator triggers the composite alarm when all the defined alarms within it are active.
   
2. **OR**: The OR operator activates the composite alarm when at least one of the defined alarms within it is active.
   
3. **NOT**: The NOT operator allows for the definition of negation, activating the composite alarm when the defined alarm is not active.

### How Can This Be Helpful?

Creating composite alarms in AWS CloudWatch can be incredibly helpful in monitoring complex infrastructures and applications. It allows for the definition of more advanced alarm rules, which can take into account multiple different factors simultaneously. For example, we can create a composite alarm that triggers only when CPU usage exceeds a certain threshold and there is also an issue with service availability.

`ALARM(RAMUtilizationTooHigh) AND ALARM(CPUUtilizationTooHigh)`

The expression specifies that the composite alarm goes into ALARM only if RAMUtilizationTooHigh and CPUUtilizationTooHighare in ALARM.

`(ALARM(RAMUtilizationTooHigh) OR ALARM(CPUUtilizationTooHigh)) AND OK(NetworkOutTooHigh)`

The expression specifies that the composite alarm goes into ALARM if (RAMUtilizationTooHigh) or (CPUUtilizationTooHigh) is in ALARM and (NetworkOutTooHigh) is in OK. This is an example of a composite alarm that reduces alarm noise by not sending you notifications when either of the underlying alarms aren’t in ALARM while a network issue is occurring.


### Utilization in Complex Notification Systems

Composite alarms are invaluable in building advanced notification systems. With them, we can define more intelligent rules that notify about issues only when they are essential for the stability or performance of the system. For instance, we can configure a notification system to send an alert only when there is both high resource consumption and a decrease in application performance.

### Summary

Composite alarms in AWS CloudWatch are powerful tools that allow for the consolidation of multiple alarms into one logical expression. They enable the creation of more advanced monitoring rules, significantly increasing the flexibility and effectiveness of monitoring systems within the AWS cloud. Utilizing composite alarms is crucial for building complex notification systems that inform about significant issues in infrastructure or applications only when necessary.

### Additional Resource: YouTube Channel

For a practical demonstration of creating simple composite alarms consisting of multiple CloudWatch alarms, you can visit my [YouTube channel](https://youtu.be/g23DEJiG8fk?feature=shared). There, you'll find a video describing this topic and see how the creation of composite alarms looks in a real cloud environment.
{% embed https://youtu.be/g23DEJiG8fk?feature=shared %}

Blog: [https://lepczynski.it/en](https://lepczynski.it/en)

AWS documentation: [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html)