diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index e49f568733..e4328a3403 100644 --- a/substrate/client/service/src/builder.rs +++ b/substrate/client/service/src/builder.rs @@ -61,7 +61,6 @@ struct ServiceMetrics { memory_usage_bytes: Gauge, cpu_usage_percentage: Gauge, network_per_sec_bytes: GaugeVec, - node_roles: Gauge, database_cache: Gauge, state_cache: Gauge, state_db: GaugeVec, @@ -87,9 +86,6 @@ impl ServiceMetrics { Opts::new("network_per_sec_bytes", "Networking bytes per second"), &["direction"] )?, registry)?, - node_roles: register(Gauge::new( - "node_roles", "The roles the node is running as", - )?, registry)?, database_cache: register(Gauge::new( "database_cache_bytes", "RocksDB cache size in bytes", )?, registry)?, @@ -1011,18 +1007,34 @@ ServiceBuilder< ); } - // Prometheus metrics + // Prometheus metrics. let metrics = if let Some(PrometheusConfig { port, registry }) = config.prometheus_config.clone() { + // Set static metrics. + register(Gauge::::with_opts( + Opts::new( + "build_info", + "A metric with a constant '1' value labeled by name, version, and commit." + ) + .const_label("name", config.impl_name) + .const_label("version", config.impl_version) + .const_label("commit", config.impl_commit), + )?, ®istry)?.set(1); + register(Gauge::::new( + "node_roles", "The roles the node is running as", + )?, ®istry)?.set(u64::from(config.roles.bits())); + let metrics = ServiceMetrics::register(®istry)?; - metrics.node_roles.set(u64::from(config.roles.bits())); + spawn_handle.spawn( "prometheus-endpoint", prometheus_endpoint::init_prometheus(port, registry).map(drop) ); + Some(metrics) } else { None }; + // Periodically notify the telemetry. let transaction_pool_ = transaction_pool.clone(); let client_ = client.clone();