Renaming an Amazon CloudWatch Alarm
Asked Answered
Z

4

8

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.

Zandrazandt answered 21/10, 2013 at 17:50 Comment(1)
Our workaround is to use the "Description" field and configure the console to display that column (it doesn't by default).Clichy
Z
9

Unfortunately it looks like this is not currently possible.

Zandrazandt answered 25/10, 2013 at 16:55 Comment(10)
Dec 2018 - still does not appear possible :-(Backhanded
OCT -2019 Still not possibleKinny
June 2021 Still not possibleGrandiloquent
Jan 2022 - Still not possible, but we gotta be close now!Eskill
I'm from the future and it's still not possible in 2023Jaquelynjaquenetta
zzzzzzzzzzzzzzzzzzzzzzzz. now 2022 it's still not possible.Suffix
Now sept 2022 it's not possible : LOLMaintain
Jan 2023 - Still not possibleDisagree
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
K
7

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.

Karykaryl answered 15/12, 2014 at 16:21 Comment(0)
C
2

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

.

Celeski answered 29/3, 2019 at 19:6 Comment(0)
V
-1

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.

Veda answered 22/7 at 23:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.