@@ -2145,9 +2145,15 @@ def alert(self, matches):
21452145 'date' : int (time .time ()) * 1000
21462146 }
21472147 alert_config .update (self .rule .get ('hive_alert_config' , {}))
2148-
2148+ custom_fields = {}
21492149 for alert_config_field , alert_config_value in alert_config .items ():
2150- if isinstance (alert_config_value , str ):
2150+ if alert_config_field == 'customFields' :
2151+ n = 0
2152+ for cf_key , cf_value in alert_config_value .items ():
2153+ cf = {'order' : n , cf_value ['type' ]: cf_value ['value' ].format (** context )}
2154+ n += 1
2155+ custom_fields [cf_key ] = cf
2156+ elif isinstance (alert_config_value , str ):
21512157 alert_config [alert_config_field ] = alert_config_value .format (** context )
21522158 elif isinstance (alert_config_value , (list , tuple )):
21532159 formatted_list = []
@@ -2157,6 +2163,8 @@ def alert(self, matches):
21572163 except (AttributeError , KeyError , IndexError ):
21582164 formatted_list .append (element )
21592165 alert_config [alert_config_field ] = formatted_list
2166+ if custom_fields :
2167+ alert_config ['customFields' ] = custom_fields
21602168
21612169 alert_body = json .dumps (alert_config , indent = 4 , sort_keys = True )
21622170 req = '{}:{}/api/alert' .format (connection_details ['hive_host' ], connection_details ['hive_port' ])
0 commit comments