Hide metric for bad with no counter data

This commit is contained in:
clerie 2024-07-21 15:04:45 +02:00
parent bd86ab8b52
commit 0c3142cc8f

View File

@ -151,13 +151,17 @@ async fn route_metrics(
let mut out = String::new();
for bad in trafficdata {
let badcounter = match bad.counter {
Some(c) => c,
None => continue,
};
let badid = escape_metric_label_value(&bad.id);
match state.baedernames.get(&bad.id) {
Some(name) => {
let badname = escape_metric_label_value(name);
out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\", badname=\"{}\"}} {}\n", badid, badname, bad.counter.unwrap_or(-1)))}
out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\", badname=\"{}\"}} {}\n", badid, badname, badcounter))}
,
None => out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\"}} {}\n", badid, bad.counter.unwrap_or(-1))),
None => out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\"}} {}\n", badid, badcounter)),
};
}