Add metrics

Change dashboards to load an index.html file compiled otherwise
This commit is contained in:
jude
2023-10-29 18:00:45 +00:00
committed by jude
parent 8ba0f02b98
commit 6e435bfc2e
10 changed files with 130 additions and 16 deletions

18
web/src/routes/metrics.rs Normal file
View File

@@ -0,0 +1,18 @@
use prometheus;
use crate::metrics::REGISTRY;
#[get("/metrics")]
pub async fn metrics() -> String {
let encoder = prometheus::TextEncoder::new();
let res_custom = encoder.encode_to_string(&REGISTRY.gather());
match res_custom {
Ok(s) => s,
Err(e) => {
warn!("Error encoding metrics: {:?}", e);
String::new()
}
}
}