format message with labels
This commit is contained in:
parent
b416009f7c
commit
3dc05fb224
|
@ -20,7 +20,7 @@ struct Alert {
|
||||||
generatorURL: String,
|
generatorURL: String,
|
||||||
startsAt: String,
|
startsAt: String,
|
||||||
annotations: AlertAnnotations,
|
annotations: AlertAnnotations,
|
||||||
// labels: HashMap<String, String>,
|
labels: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, Debug)]
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
|
@ -51,7 +51,11 @@ async fn alerts(
|
||||||
if message != "" {
|
if message != "" {
|
||||||
message += "\n";
|
message += "\n";
|
||||||
}
|
}
|
||||||
message += &format!("{}: {}", alert.annotations.summary, alert.generatorURL);
|
let title = match (alert.labels.get("alertname"), alert.labels.get("instance")) {
|
||||||
|
(Some(name), Some(instance)) => format!("{}@{}", name, instance),
|
||||||
|
_ => alert.annotations.summary.clone(),
|
||||||
|
};
|
||||||
|
message += &format!("{}: {}", title, alert.generatorURL);
|
||||||
alerts.insert(alert.generatorURL.clone(), alert);
|
alerts.insert(alert.generatorURL.clone(), alert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue