@@ -2145,9 +2145,15 @@ def alert(self, matches):
2145
2145
'date' : int (time .time ()) * 1000
2146
2146
}
2147
2147
alert_config .update (self .rule .get ('hive_alert_config' , {}))
2148
-
2148
+ custom_fields = {}
2149
2149
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 ):
2151
2157
alert_config [alert_config_field ] = alert_config_value .format (** context )
2152
2158
elif isinstance (alert_config_value , (list , tuple )):
2153
2159
formatted_list = []
@@ -2157,6 +2163,8 @@ def alert(self, matches):
2157
2163
except (AttributeError , KeyError , IndexError ):
2158
2164
formatted_list .append (element )
2159
2165
alert_config [alert_config_field ] = formatted_list
2166
+ if custom_fields :
2167
+ alert_config ['customFields' ] = custom_fields
2160
2168
2161
2169
alert_body = json .dumps (alert_config , indent = 4 , sort_keys = True )
2162
2170
req = '{}:{}/api/alert' .format (connection_details ['hive_host' ], connection_details ['hive_port' ])
0 commit comments