Skip to content

Commit 9cb7c7f

Browse files
authored
Add deployment ID to Alertmananger (#314)
Part of #311
1 parent 4093b5c commit 9cb7c7f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

server/src/alerts/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub mod rule;
2424
pub mod target;
2525

2626
use crate::metrics::ALERTS_STATES;
27-
use crate::utils::uid::Uid;
27+
use crate::storage;
28+
use crate::utils::uid;
2829

2930
pub use self::rule::Rule;
3031
use self::target::Target;
@@ -39,7 +40,7 @@ pub struct Alerts {
3940
#[serde(rename_all = "camelCase")]
4041
pub 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

9599
impl 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

server/src/alerts/target.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)