3636
3737
3838class GrafanaEngine :
39-
4039 # Configure a larger HTTP request pool.
4140 # TODO: Review the pool settings and eventually adjust according to concurrency level or other parameters.
4241 # https://urllib3.readthedocs.io/en/latest/advanced-usage.html#customizing-pool-behavior
@@ -589,7 +588,11 @@ def channels_list(self):
589588 return self .grafana .notifications .lookup_channels ()
590589
591590 def channels_list_by_uid (self , channel_uid ):
592- channel = self .grafana .notifications .get_channel_by_uid (channel_uid )
591+ try :
592+ channel = self .grafana .notifications .get_channel_by_uid (channel_uid )
593+ except GrafanaClientError as ex :
594+ log .error (f"Error fetching the channel { channel_uid } : { ex } " )
595+ raise SystemExit (1 )
593596
594597 # Scan dashboards and panels to find where the channel is used
595598 dashboards = self .scan_dashboards ()
@@ -616,6 +619,19 @@ def extract_channel_related_information(channel_uid, dashboard, panel):
616619 related_information .append ({"dashboard" : dashboard ["dashboard" ]["title" ], "panel" : panel ["title" ]})
617620 return related_information
618621
622+ def channels_list_by_name (self , name ):
623+ channel_list = self .channels_list ()
624+ channel_uid = ""
625+ for channel in channel_list :
626+ if channel ["name" ] == name :
627+ channel_uid = channel ["uid" ]
628+ break
629+ if channel_uid :
630+ return self .channels_list_by_uid (channel_uid )
631+ else :
632+ log .info (f"Channel with the name { name } doesn't exist" )
633+ raise SystemExit (0 )
634+
619635
620636class Indexer :
621637 def __init__ (self , engine : GrafanaWtf ):
0 commit comments