format message with labels
This commit is contained in:
parent
b416009f7c
commit
3dc05fb224
|
@ -20,7 +20,7 @@ struct Alert {
|
|||
generatorURL: String,
|
||||
startsAt: String,
|
||||
annotations: AlertAnnotations,
|
||||
// labels: HashMap<String, String>,
|
||||
labels: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
|
@ -51,7 +51,11 @@ async fn alerts(
|
|||
if message != "" {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue