Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spawned-rt = "0.5.0"
tokio = "1.0"
tokio-util = "0.7"

prometheus = "0.14"
prometheus = { version = "0.14", features = ["process"] }

clap = { version = "4.3", features = ["derive", "env"] }

Expand Down
18 changes: 18 additions & 0 deletions crates/common/metrics/src/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ pub fn gather_default_metrics() -> Result<String, GatherError> {

Ok(res)
}

/// The process collector comes from the `prometheus` crate's `process`
/// feature, which registers it with the default registry on Linux only.
/// Dashboards read the node's memory from it, so dropping the feature would
/// leave them blank without any build failing.
#[cfg(all(test, target_os = "linux"))]
mod tests {
use super::*;

#[test]
fn the_default_registry_serves_the_process_metrics() {
let metrics = gather_default_metrics().unwrap();
assert!(
metrics.contains("process_resident_memory_bytes"),
"{metrics}"
);
}
}
7 changes: 7 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ The Lean Chain's metrics follow [the leanMetrics specification](https://github.c
| `lean_node_info` | Gauge | Node information (always 1) | On node start | name, version | ✅ |
| `lean_node_start_time_seconds` | Gauge | Start timestamp | On node start | | ✅ |

On Linux the endpoint also serves the `prometheus` crate's process collector,
read from `/proc/self` at each scrape: `process_resident_memory_bytes`,
`process_virtual_memory_bytes`, `process_cpu_seconds_total`,
`process_open_fds`, `process_max_fds`, `process_threads` and
`process_start_time_seconds`. They are not part of the leanMetrics spec, and
other platforms do not export them.


## PQ Signature Metrics

Expand Down
Loading