@@ -303,15 +303,26 @@ impl AlertTrait for ThresholdAlert {
303
303
}
304
304
305
305
impl MessageCreation for ThresholdAlert {
306
+ fn get_message_header ( & self ) -> Result < String , AlertError > {
307
+ Ok ( format ! (
308
+ "Alert Name: {}\n Alert Type: Threshold alert\n Severity: {}\n Triggered at: {}\n Threshold: {}\n Alert ID: {}\n Evaluation Window: {}\n Frequency: {}\n \n Values crossing the threshold:" ,
309
+ self . title,
310
+ self . severity,
311
+ Utc :: now( ) . to_rfc3339( ) ,
312
+ format_args!(
313
+ "{} {}" ,
314
+ self . threshold_config. operator, self . threshold_config. value
315
+ ) ,
316
+ self . id,
317
+ self . get_eval_window( ) ,
318
+ self . get_eval_frequency( )
319
+ ) )
320
+ }
306
321
fn create_threshold_message ( & self , actual_value : f64 ) -> Result < String , AlertError > {
322
+ let header = self . get_message_header ( ) ?;
307
323
Ok ( format ! (
308
- "Alert Triggered: {}\n \n Threshold: ({} {})\n Current Value: {}\n Evaluation Window: {} | Frequency: {}\n \n Query:\n {}" ,
309
- self . get_id( ) ,
310
- self . get_threshold_config( ) . operator,
311
- self . get_threshold_config( ) . value,
324
+ "{header}\n Value: {}\n \n Query:\n {}" ,
312
325
actual_value,
313
- self . get_eval_window( ) ,
314
- self . get_eval_frequency( ) ,
315
326
self . get_query( )
316
327
) )
317
328
}
@@ -384,14 +395,8 @@ impl From<ThresholdAlert> for AlertConfig {
384
395
385
396
impl ThresholdAlert {
386
397
fn create_group_message ( & self , breached_groups : & [ GroupResult ] ) -> Result < String , AlertError > {
387
- let mut message = format ! (
388
- "Alert Triggered: {}\n \n Threshold: ({} {})\n Evaluation Window: {} | Frequency: {}\n \n " ,
389
- self . get_id( ) ,
390
- self . get_threshold_config( ) . operator,
391
- self . get_threshold_config( ) . value,
392
- self . get_eval_window( ) ,
393
- self . get_eval_frequency( )
394
- ) ;
398
+ let header = self . get_message_header ( ) ?;
399
+ let mut message = format ! ( "{header}\n " ) ;
395
400
396
401
message. push_str ( & format ! (
397
402
"Alerting Groups ({} total):\n " ,
0 commit comments