@@ -545,12 +545,14 @@ impl AlertRequest {
545
545
for id in & self . targets {
546
546
TARGETS . get_target_by_id ( id) . await ?;
547
547
}
548
+ let datasets = resolve_stream_names ( & self . query ) ?;
548
549
let config = AlertConfig {
549
550
version : AlertVerison :: from ( CURRENT_ALERTS_VERSION ) ,
550
551
id : Ulid :: new ( ) ,
551
552
severity : self . severity ,
552
553
title : self . title ,
553
554
query : self . query ,
555
+ datasets,
554
556
alert_type : self . alert_type ,
555
557
threshold_config : self . threshold_config ,
556
558
eval_config : self . eval_config ,
@@ -572,6 +574,7 @@ pub struct AlertConfig {
572
574
pub severity : Severity ,
573
575
pub title : String ,
574
576
pub query : String ,
577
+ pub datasets : Vec < String > ,
575
578
pub alert_type : AlertType ,
576
579
pub threshold_config : ThresholdConfig ,
577
580
pub eval_config : EvalConfig ,
@@ -593,6 +596,7 @@ impl AlertConfig {
593
596
let alert_info = format ! ( "Alert '{}' (ID: {})" , basic_fields. title, basic_fields. id) ;
594
597
595
598
let query = Self :: build_query_from_v1 ( alert_json, & alert_info) . await ?;
599
+ let datasets = resolve_stream_names ( & query) ?;
596
600
let threshold_config = Self :: extract_threshold_config ( alert_json, & alert_info) ?;
597
601
let eval_config = Self :: extract_eval_config ( alert_json, & alert_info) ?;
598
602
let targets = Self :: extract_targets ( alert_json, & alert_info) ?;
@@ -605,6 +609,7 @@ impl AlertConfig {
605
609
severity : basic_fields. severity ,
606
610
title : basic_fields. title ,
607
611
query,
612
+ datasets,
608
613
alert_type : AlertType :: Threshold ,
609
614
threshold_config,
610
615
eval_config,
@@ -1245,6 +1250,16 @@ impl AlertConfig {
1245
1250
) ;
1246
1251
}
1247
1252
1253
+ map. insert (
1254
+ "datasets" . to_string ( ) ,
1255
+ serde_json:: Value :: Array (
1256
+ self . datasets
1257
+ . iter ( )
1258
+ . map ( |dataset| serde_json:: Value :: String ( dataset. clone ( ) ) )
1259
+ . collect ( ) ,
1260
+ ) ,
1261
+ ) ;
1262
+
1248
1263
map
1249
1264
}
1250
1265
}
0 commit comments