I'm trying to organize a large number of CloudWatch alarms for maintainability, and the web console grays out the name field on an edit. Is there another method (preferably something scriptable) for updating the name of CloudWatch alarms? I would prefer a solution that does not require any programming beyond simple executable scripts.
Renaming an Amazon CloudWatch Alarm
Asked Answered
Our workaround is to use the "Description" field and configure the console to display that column (it doesn't by default). –
Clichy
Unfortunately it looks like this is not currently possible.
Dec 2018 - still does not appear possible :-( –
Backhanded
OCT -2019 Still not possible –
Kinny
June 2021 Still not possible –
Grandiloquent
Jan 2022 - Still not possible, but we gotta be close now! –
Eskill
I'm from the future and it's still not possible in 2023 –
Jaquelynjaquenetta
zzzzzzzzzzzzzzzzzzzzzzzz. now 2022 it's still not possible. –
Suffix
Now sept 2022 it's not possible : LOL –
Maintain
Jan 2023 - Still not possible –
Disagree
Jun1 2023 - seems like you can copy the alarm and rename it that way - copy/delete original? –
Barytes
May 29, 2024 - Still not possible. –
Mallen
Here's a script we use to do this for the time being:
import sys
import boto
def rename_alarm(alarm_name, new_alarm_name):
conn = boto.connect_cloudwatch()
def get_alarm():
alarms = conn.describe_alarms(alarm_names=[alarm_name])
if not alarms:
raise Exception("Alarm '%s' not found" % alarm_name)
return alarms[0]
alarm = get_alarm()
# work around boto comparison serialization issue
# https://github.com/boto/boto/issues/1311
alarm.comparison = alarm._cmp_map.get(alarm.comparison)
alarm.name = new_alarm_name
conn.update_alarm(alarm)
# update actually creates a new alarm because the name has changed, so
# we have to manually delete the old one
get_alarm().delete()
if __name__ == '__main__':
alarm_name, new_alarm_name = sys.argv[1:3]
rename_alarm(alarm_name, new_alarm_name)
It assumes you're either on an ec2 instance with a role that allows this, or you've got a ~/.boto file with your credentials. It's easy enough to manually add yours.
I looked around for the same solution but it seems neither console nor cloudwatch API provides that feature.
Note:
But we can copy the existing alram with the same parameter and can save on new name
.
If you use Terraform to manage your CloudWatch alarms, you can easily change the alarm resource's name and Terraform will recreate the alarm with the new name.
© 2022 - 2024 — McMap. All rights reserved.