diff --git a/src/save_alert_channels.py b/src/save_alert_channels.py index 4a800e5e92d8c21857eaf38f9a7923549e88ba3e..17107f2942b155c8d9c502d3bed2a178f78e7df2 100644 --- a/src/save_alert_channels.py +++ b/src/save_alert_channels.py @@ -30,14 +30,19 @@ def save_alert_channel(channel_name, file_name, alert_channel_setting): def get_indivisual_alert_channel_and_save(channels): for channel in channels: + if 'uid' in channel: + channel_identifier = channel['uid'] + else: + channel_identifier = channel['id'] + save_alert_channel( to_python2_and_3_compatible_string(channel['name']), - to_python2_and_3_compatible_string(channel['id']), + to_python2_and_3_compatible_string(channel_identifier), channel ) file_path = folder_path + '/' + log_file with open(u"{0}".format(file_path) , 'w+') as f: - f.write('{}\t{}'.format(to_python2_and_3_compatible_string(channel['id']), to_python2_and_3_compatible_string(channel['name']))) + f.write('{}\t{}'.format(to_python2_and_3_compatible_string(channel_identifier), to_python2_and_3_compatible_string(channel['name']))) alert_channels = get_all_alert_channels_in_grafana()