diff --git a/bin/ethlambda/src/main.rs b/bin/ethlambda/src/main.rs index fabacb7..a90d70e 100644 --- a/bin/ethlambda/src/main.rs +++ b/bin/ethlambda/src/main.rs @@ -84,6 +84,9 @@ async fn main() -> eyre::Result<()> { // Set node info metrics ethlambda_blockchain::metrics::set_node_info("ethlambda", version::CLIENT_VERSION); ethlambda_blockchain::metrics::set_node_start_time(); + ethlambda_blockchain::metrics::set_attestation_committee_count( + options.attestation_committee_count, + ); let api_socket = SocketAddr::new(options.http_address, options.api_port); let metrics_socket = SocketAddr::new(options.http_address, options.metrics_port); diff --git a/crates/blockchain/src/metrics.rs b/crates/blockchain/src/metrics.rs index c44d369..88c5817 100644 --- a/crates/blockchain/src/metrics.rs +++ b/crates/blockchain/src/metrics.rs @@ -358,6 +358,19 @@ pub fn set_is_aggregator(is_aggregator: bool) { LEAN_IS_AGGREGATOR.set(i64::from(is_aggregator)); } +/// Set the attestation committee count gauge. +pub fn set_attestation_committee_count(count: u64) { + static LEAN_ATTESTATION_COMMITTEE_COUNT: std::sync::LazyLock = + std::sync::LazyLock::new(|| { + register_int_gauge!( + "lean_attestation_committee_count", + "Number of attestation committees (ATTESTATION_COMMITTEE_COUNT)" + ) + .unwrap() + }); + LEAN_ATTESTATION_COMMITTEE_COUNT.set(count.try_into().unwrap_or_default()); +} + /// Observe the depth of a fork choice reorg. pub fn observe_fork_choice_reorg_depth(depth: u64) { static LEAN_FORK_CHOICE_REORG_DEPTH: std::sync::LazyLock = diff --git a/docs/metrics.md b/docs/metrics.md index 734beac..5094b72 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -73,6 +73,7 @@ The exposed metrics follow [the leanMetrics specification](https://github.com/le | Name | Type | Usage | Sample collection event | Labels | Supported | |--------|-------|-------|-------------------------|--------|-----------| +|`lean_attestation_committee_count`| Gauge | Number of attestation committees | On node start | | ✅ | |`lean_connected_peers`| Gauge | Number of connected peers | On scrape | client=ethlambda,grandine,lantern,lighthouse,qlean,ream,zeam | ✅(*) | |`lean_peer_connection_events_total`| Counter | Total number of peer connection events | On peer connection | direction=inbound,outbound
result=success,timeout,error | ✅ | |`lean_peer_disconnection_events_total`| Counter | Total number of peer disconnection events | On peer disconnection | direction=inbound,outbound
reason=timeout,remote_close,local_close,error | ✅ |