diff options
Diffstat (limited to 'src/api/stats')
| -rw-r--r-- | src/api/stats/prometheus.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/api/stats/prometheus.rs b/src/api/stats/prometheus.rs index d29207c..74c18e9 100644 --- a/src/api/stats/prometheus.rs +++ b/src/api/stats/prometheus.rs @@ -54,6 +54,45 @@ impl Out { } } +const DISK_COUNTERS: usize = 7; + +/// Name, help and value of each counter of one kind of file. +fn disk_counters(c: &super::DiskStats) -> [(&'static str, &'static str, u64); DISK_COUNTERS] { + [ + ( + "disk_reads_total", + "Reads of this node's own files.", + c.reads, + ), + ( + "disk_read_bytes_total", + "Bytes read from them.", + c.read_bytes, + ), + ("disk_writes_total", "Whole files written.", c.writes), + ( + "disk_written_bytes_total", + "Bytes of them.", + c.written_bytes, + ), + ( + "disk_appends_total", + "Appends to this node's own files.", + c.appends, + ), + ( + "disk_appended_bytes_total", + "Bytes appended.", + c.appended_bytes, + ), + ( + "disk_errors_total", + "Failed reads, writes and appends.", + c.errors, + ), + ] +} + fn escape(value: &str) -> String { value .replace('\\', "\\\\") @@ -130,6 +169,7 @@ fn traffic_series(traffic: &PeerTraffic) -> Vec<(&'static str, &'static str, Cou (direction, "sync", by.sync), (direction, "ping", by.ping), (direction, "pong", by.pong), + (direction, "blob", by.blob), ] }; let mut series = Vec::new(); @@ -296,6 +336,16 @@ pub(super) async fn render(state: &AppState, stats: &StatsResponse) -> String { stats.stale_hello_replies as f64, ); + for counter in 0..DISK_COUNTERS { + for (i, (kind, counts)) in stats.disk.iter().enumerate() { + let (name, help, value) = disk_counters(counts)[counter]; + if i == 0 { + out.family(name, "counter", help); + } + out.sample(name, &[("file", *kind)], value as f64); + } + } + let propagation = &stats.propagation; out.family( "propagation_delay_seconds", |
