aws-samples / amazon-cloudwatch-auto-alarms

Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
MIT No Attribution
90 stars 84 forks source link

Feature/add description to end of alarm name #21

Closed GlennChia closed 1 year ago

GlennChia commented 1 year ago

Issue #, if available:

Description of changes:

Currently alarms created cannot have similar settings and different thresholds because the put_metric_alarm replaces alarms with the same name (the key that goes into the alarm name is the same). This means we cannot have alarms that have similar settings but different thresholds. Adding a description to the end of the alarm name differentiates alarms. This description is added to the Tag Key and the Default map of keys and is appended to the end of the alarm name. Hence, we can now have alarms with similar settings but different thresholds.

To ensure backward compatibility, we check if the last element exists by using properties_offset + 6. If there is an error, that means users have not entered a description. In this situation, we just log that the user did not specify a description. The behaviour of their alarms would remain the same.

However, if users have old alarms without a description and suddenly add the description in, the old alarms will not be deleted. Instead, only the new alarms with the description will be created.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.