File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ pub mod rule;
2424pub mod target;
2525
2626use crate :: metrics:: ALERTS_STATES ;
27- use crate :: utils:: uid:: Uid ;
27+ use crate :: storage;
28+ use crate :: utils:: uid;
2829
2930pub use self :: rule:: Rule ;
3031use self :: target:: Target ;
@@ -39,7 +40,7 @@ pub struct Alerts {
3940#[ serde( rename_all = "camelCase" ) ]
4041pub struct Alert {
4142 #[ serde( default = "crate::utils::uid::gen" ) ]
42- pub id : Uid ,
43+ pub id : uid :: Uid ,
4344 pub name : String ,
4445 pub message : String ,
4546 pub rule : Rule ,
@@ -69,12 +70,14 @@ impl Alert {
6970 }
7071
7172 fn get_context ( & self , stream_name : String , alert_state : AlertState ) -> Context {
73+ let deployment_id = storage:: StorageMetadata :: global ( ) . deployment_id ;
7274 Context :: new (
7375 stream_name,
7476 self . name . clone ( ) ,
7577 self . message . clone ( ) ,
7678 self . rule . trigger_reason ( ) ,
7779 alert_state,
80+ deployment_id,
7881 )
7982 }
8083}
@@ -90,6 +93,7 @@ pub struct Context {
9093 message : String ,
9194 reason : String ,
9295 alert_state : AlertState ,
96+ deployment_id : uid:: Uid ,
9397}
9498
9599impl Context {
@@ -99,13 +103,15 @@ impl Context {
99103 message : String ,
100104 reason : String ,
101105 alert_state : AlertState ,
106+ deployment_id : uid:: Uid ,
102107 ) -> Self {
103108 Self {
104109 stream,
105110 alert_name,
106111 message,
107112 reason,
108113 alert_state,
114+ deployment_id,
109115 }
110116 }
111117
Original file line number Diff line number Diff line change @@ -317,6 +317,7 @@ impl CallableTarget for AlertManager {
317317 "labels" : {
318318 "alertname" : payload. alert_name,
319319 "stream" : payload. stream,
320+ "deployment_id" : payload. deployment_id
320321 } ,
321322 "annotations" : {
322323 "message" : payload. message,
You can’t perform that action at this time.
0 commit comments