Remove Prometheus metrics prefix (#9543)

* Remove Prometheus metrics prefix

* Fix line widths

* Missed some metrics

* Fix CLI

* Run rustfmt on modified files

* Missing prefixes

* Hopefully fix compilation

* Rustfmt protocol.rs

* Should compile now I guess

* Rustfmt

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Pierre Krieger
2021-12-09 11:21:27 +01:00
committed by GitHub
parent 667dec91bf
commit 443bdc20d6
21 changed files with 125 additions and 102 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ impl<Block: BlockT> StorageNotifications<Block> {
let metrics = prometheus_registry.and_then(|r| { let metrics = prometheus_registry.and_then(|r| {
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"storage_notification_subscribers", "substrate_storage_notification_subscribers",
"Number of subscribers in storage notification sytem", "Number of subscribers in storage notification sytem",
), ),
&["action"], // added | removed &["action"], // added | removed
@@ -733,14 +733,14 @@ impl Metrics {
Ok(Self { Ok(Self {
publish: register( publish: register(
Counter::new( Counter::new(
"authority_discovery_times_published_total", "substrate_authority_discovery_times_published_total",
"Number of times authority discovery has published external addresses.", "Number of times authority discovery has published external addresses.",
)?, )?,
registry, registry,
)?, )?,
amount_addresses_last_published: register( amount_addresses_last_published: register(
Gauge::new( Gauge::new(
"authority_discovery_amount_external_addresses_last_published", "substrate_authority_discovery_amount_external_addresses_last_published",
"Number of external addresses published when authority discovery last \ "Number of external addresses published when authority discovery last \
published addresses.", published addresses.",
)?, )?,
@@ -748,7 +748,7 @@ impl Metrics {
)?, )?,
requests: register( requests: register(
Counter::new( Counter::new(
"authority_discovery_authority_addresses_requested_total", "substrate_authority_discovery_authority_addresses_requested_total",
"Number of times authority discovery has requested external addresses of a \ "Number of times authority discovery has requested external addresses of a \
single authority.", single authority.",
)?, )?,
@@ -756,7 +756,7 @@ impl Metrics {
)?, )?,
requests_pending: register( requests_pending: register(
Gauge::new( Gauge::new(
"authority_discovery_authority_address_requests_pending", "substrate_authority_discovery_authority_address_requests_pending",
"Number of pending authority address requests.", "Number of pending authority address requests.",
)?, )?,
registry, registry,
@@ -764,7 +764,7 @@ impl Metrics {
dht_event_received: register( dht_event_received: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"authority_discovery_dht_event_received", "substrate_authority_discovery_dht_event_received",
"Number of dht events received by authority discovery.", "Number of dht events received by authority discovery.",
), ),
&["name"], &["name"],
@@ -773,14 +773,14 @@ impl Metrics {
)?, )?,
handle_value_found_event_failure: register( handle_value_found_event_failure: register(
Counter::new( Counter::new(
"authority_discovery_handle_value_found_event_failure", "substrate_authority_discovery_handle_value_found_event_failure",
"Number of times handling a dht value found event failed.", "Number of times handling a dht value found event failed.",
)?, )?,
registry, registry,
)?, )?,
known_authorities_count: register( known_authorities_count: register(
Gauge::new( Gauge::new(
"authority_discovery_known_authorities_count", "substrate_authority_discovery_known_authorities_count",
"Number of authorities known by authority discovery.", "Number of authorities known by authority discovery.",
)?, )?,
registry, registry,
+12 -6
View File
@@ -40,28 +40,34 @@ impl Metrics {
pub(crate) fn register(registry: &Registry) -> Result<Self, PrometheusError> { pub(crate) fn register(registry: &Registry) -> Result<Self, PrometheusError> {
Ok(Self { Ok(Self {
beefy_validator_set_id: register( beefy_validator_set_id: register(
Gauge::new("beefy_validator_set_id", "Current BEEFY active validator set id.")?, Gauge::new(
"substrate_beefy_validator_set_id",
"Current BEEFY active validator set id.",
)?,
registry, registry,
)?, )?,
beefy_votes_sent: register( beefy_votes_sent: register(
Counter::new("beefy_votes_sent", "Number of votes sent by this node")?, Counter::new("substrate_beefy_votes_sent", "Number of votes sent by this node")?,
registry, registry,
)?, )?,
beefy_round_concluded: register( beefy_round_concluded: register(
Gauge::new("beefy_round_concluded", "Voting round, that has been concluded")?, Gauge::new(
"substrate_beefy_round_concluded",
"Voting round, that has been concluded",
)?,
registry, registry,
)?, )?,
beefy_best_block: register( beefy_best_block: register(
Gauge::new("beefy_best_block", "Best block finalized by BEEFY")?, Gauge::new("substrate_beefy_best_block", "Best block finalized by BEEFY")?,
registry, registry,
)?, )?,
beefy_should_vote_on: register( beefy_should_vote_on: register(
Gauge::new("beefy_should_vote_on", "Next block, BEEFY should vote on")?, Gauge::new("substrate_beefy_should_vote_on", "Next block, BEEFY should vote on")?,
registry, registry,
)?, )?,
beefy_skipped_sessions: register( beefy_skipped_sessions: register(
Counter::new( Counter::new(
"beefy_skipped_sessions", "substrate_beefy_skipped_sessions",
"Number of sessions without a signed commitment", "Number of sessions without a signed commitment",
)?, )?,
registry, registry,
+7 -4
View File
@@ -368,10 +368,13 @@ impl CliConfiguration for RunCmd {
let interface = let interface =
if self.prometheus_external { Ipv4Addr::UNSPECIFIED } else { Ipv4Addr::LOCALHOST }; if self.prometheus_external { Ipv4Addr::UNSPECIFIED } else { Ipv4Addr::LOCALHOST };
Some(PrometheusConfig::new_with_default_registry(SocketAddr::new( Some(PrometheusConfig::new_with_default_registry(
interface.into(), SocketAddr::new(
self.prometheus_port.unwrap_or(default_listen_port), interface.into(),
))) self.prometheus_port.unwrap_or(default_listen_port),
),
self.shared_params.chain_id(self.shared_params.dev),
))
}) })
} }
@@ -41,28 +41,34 @@ impl Metrics {
Ok(Self { Ok(Self {
import_queue_processed: register( import_queue_processed: register(
CounterVec::new( CounterVec::new(
Opts::new("import_queue_processed_total", "Blocks processed by import queue"), Opts::new(
"substrate_import_queue_processed_total",
"Blocks processed by import queue",
),
&["result"], // 'success or failure &["result"], // 'success or failure
)?, )?,
registry, registry,
)?, )?,
block_verification_time: register( block_verification_time: register(
HistogramVec::new( HistogramVec::new(
HistogramOpts::new("block_verification_time", "Time taken to verify blocks"), HistogramOpts::new(
"substrate_block_verification_time",
"Time taken to verify blocks",
),
&["result"], &["result"],
)?, )?,
registry, registry,
)?, )?,
block_verification_and_import_time: register( block_verification_and_import_time: register(
Histogram::with_opts(HistogramOpts::new( Histogram::with_opts(HistogramOpts::new(
"block_verification_and_import_time", "substrate_block_verification_and_import_time",
"Time taken to verify and import blocks", "Time taken to verify and import blocks",
))?, ))?,
registry, registry,
)?, )?,
justification_import_time: register( justification_import_time: register(
Histogram::with_opts(HistogramOpts::new( Histogram::with_opts(HistogramOpts::new(
"justification_import_time", "substrate_justification_import_time",
"Time taken to import justifications", "Time taken to import justifications",
))?, ))?,
registry, registry,
@@ -1299,7 +1299,7 @@ impl Metrics {
messages_validated: register( messages_validated: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"finality_grandpa_communication_gossip_validator_messages", "substrate_finality_grandpa_communication_gossip_validator_messages",
"Number of messages validated by the finality grandpa gossip validator.", "Number of messages validated by the finality grandpa gossip validator.",
), ),
&["message", "action"], &["message", "action"],
@@ -404,19 +404,19 @@ impl Metrics {
) -> Result<Self, PrometheusError> { ) -> Result<Self, PrometheusError> {
Ok(Self { Ok(Self {
finality_grandpa_round: register( finality_grandpa_round: register(
Gauge::new("finality_grandpa_round", "Highest completed GRANDPA round.")?, Gauge::new("substrate_finality_grandpa_round", "Highest completed GRANDPA round.")?,
registry, registry,
)?, )?,
finality_grandpa_prevotes: register( finality_grandpa_prevotes: register(
Counter::new( Counter::new(
"finality_grandpa_prevotes_total", "substrate_finality_grandpa_prevotes_total",
"Total number of GRANDPA prevotes cast locally.", "Total number of GRANDPA prevotes cast locally.",
)?, )?,
registry, registry,
)?, )?,
finality_grandpa_precommits: register( finality_grandpa_precommits: register(
Counter::new( Counter::new(
"finality_grandpa_precommits_total", "substrate_finality_grandpa_precommits_total",
"Total number of GRANDPA precommits cast locally.", "Total number of GRANDPA precommits cast locally.",
)?, )?,
registry, registry,
@@ -100,7 +100,7 @@ impl Metrics {
Ok(Self { Ok(Self {
global_waiting_messages: register( global_waiting_messages: register(
Gauge::new( Gauge::new(
"finality_grandpa_until_imported_waiting_messages_number", "substrate_finality_grandpa_until_imported_waiting_messages_number",
"Number of finality grandpa messages waiting within the until imported queue.", "Number of finality grandpa messages waiting within the until imported queue.",
)?, )?,
registry, registry,
@@ -508,14 +508,14 @@ impl Metrics {
Ok(Self { Ok(Self {
registered_messages: register( registered_messages: register(
Counter::new( Counter::new(
"network_gossip_registered_messages_total", "substrate_network_gossip_registered_messages_total",
"Number of registered messages by the gossip service.", "Number of registered messages by the gossip service.",
)?, )?,
registry, registry,
)?, )?,
expired_messages: register( expired_messages: register(
Counter::new( Counter::new(
"network_gossip_expired_messages_total", "substrate_network_gossip_expired_messages_total",
"Number of expired messages by the gossip service.", "Number of expired messages by the gossip service.",
)?, )?,
registry, registry,
+5 -4
View File
@@ -132,21 +132,22 @@ impl Metrics {
fn register(r: &Registry) -> Result<Self, PrometheusError> { fn register(r: &Registry) -> Result<Self, PrometheusError> {
Ok(Self { Ok(Self {
peers: { peers: {
let g = Gauge::new("sync_peers", "Number of peers we sync with")?; let g = Gauge::new("substrate_sync_peers", "Number of peers we sync with")?;
register(g, r)? register(g, r)?
}, },
queued_blocks: { queued_blocks: {
let g = Gauge::new("sync_queued_blocks", "Number of blocks in import queue")?; let g =
Gauge::new("substrate_sync_queued_blocks", "Number of blocks in import queue")?;
register(g, r)? register(g, r)?
}, },
fork_targets: { fork_targets: {
let g = Gauge::new("sync_fork_targets", "Number of fork sync targets")?; let g = Gauge::new("substrate_sync_fork_targets", "Number of fork sync targets")?;
register(g, r)? register(g, r)?
}, },
justifications: { justifications: {
let g = GaugeVec::new( let g = GaugeVec::new(
Opts::new( Opts::new(
"sync_extra_justifications", "substrate_sync_extra_justifications",
"Number of extra justifications requests", "Number of extra justifications requests",
), ),
&["status"], &["status"],
+33 -30
View File
@@ -84,54 +84,54 @@ impl Metrics {
// This list is ordered alphabetically // This list is ordered alphabetically
connections_closed_total: prometheus::register(CounterVec::new( connections_closed_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_connections_closed_total", "substrate_sub_libp2p_connections_closed_total",
"Total number of connections closed, by direction and reason" "Total number of connections closed, by direction and reason"
), ),
&["direction", "reason"] &["direction", "reason"]
)?, registry)?, )?, registry)?,
connections_opened_total: prometheus::register(CounterVec::new( connections_opened_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_connections_opened_total", "substrate_sub_libp2p_connections_opened_total",
"Total number of connections opened by direction" "Total number of connections opened by direction"
), ),
&["direction"] &["direction"]
)?, registry)?, )?, registry)?,
distinct_peers_connections_closed_total: prometheus::register(Counter::new( distinct_peers_connections_closed_total: prometheus::register(Counter::new(
"sub_libp2p_distinct_peers_connections_closed_total", "substrate_sub_libp2p_distinct_peers_connections_closed_total",
"Total number of connections closed with distinct peers" "Total number of connections closed with distinct peers"
)?, registry)?, )?, registry)?,
distinct_peers_connections_opened_total: prometheus::register(Counter::new( distinct_peers_connections_opened_total: prometheus::register(Counter::new(
"sub_libp2p_distinct_peers_connections_opened_total", "substrate_sub_libp2p_distinct_peers_connections_opened_total",
"Total number of connections opened with distinct peers" "Total number of connections opened with distinct peers"
)?, registry)?, )?, registry)?,
import_queue_blocks_submitted: prometheus::register(Counter::new( import_queue_blocks_submitted: prometheus::register(Counter::new(
"import_queue_blocks_submitted", "substrate_import_queue_blocks_submitted",
"Number of blocks submitted to the import queue.", "Number of blocks submitted to the import queue.",
)?, registry)?, )?, registry)?,
import_queue_justifications_submitted: prometheus::register(Counter::new( import_queue_justifications_submitted: prometheus::register(Counter::new(
"import_queue_justifications_submitted", "substrate_import_queue_justifications_submitted",
"Number of justifications submitted to the import queue.", "Number of justifications submitted to the import queue.",
)?, registry)?, )?, registry)?,
incoming_connections_errors_total: prometheus::register(CounterVec::new( incoming_connections_errors_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_incoming_connections_handshake_errors_total", "substrate_sub_libp2p_incoming_connections_handshake_errors_total",
"Total number of incoming connections that have failed during the \ "Total number of incoming connections that have failed during the \
initial handshake" initial handshake"
), ),
&["reason"] &["reason"]
)?, registry)?, )?, registry)?,
incoming_connections_total: prometheus::register(Counter::new( incoming_connections_total: prometheus::register(Counter::new(
"sub_libp2p_incoming_connections_total", "substrate_sub_libp2p_incoming_connections_total",
"Total number of incoming connections on the listening sockets" "Total number of incoming connections on the listening sockets"
)?, registry)?, )?, registry)?,
issued_light_requests: prometheus::register(Counter::new( issued_light_requests: prometheus::register(Counter::new(
"issued_light_requests", "substrate_issued_light_requests",
"Number of light client requests that our node has issued.", "Number of light client requests that our node has issued.",
)?, registry)?, )?, registry)?,
kademlia_query_duration: prometheus::register(HistogramVec::new( kademlia_query_duration: prometheus::register(HistogramVec::new(
HistogramOpts { HistogramOpts {
common_opts: Opts::new( common_opts: Opts::new(
"sub_libp2p_kademlia_query_duration", "substrate_sub_libp2p_kademlia_query_duration",
"Duration of Kademlia queries per query type" "Duration of Kademlia queries per query type"
), ),
buckets: prometheus::exponential_buckets(0.5, 2.0, 10) buckets: prometheus::exponential_buckets(0.5, 2.0, 10)
@@ -141,43 +141,44 @@ impl Metrics {
)?, registry)?, )?, registry)?,
kademlia_random_queries_total: prometheus::register(CounterVec::new( kademlia_random_queries_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_kademlia_random_queries_total", "substrate_sub_libp2p_kademlia_random_queries_total",
"Number of random Kademlia queries started" "Number of random Kademlia queries started"
), ),
&["protocol"] &["protocol"]
)?, registry)?, )?, registry)?,
kademlia_records_count: prometheus::register(GaugeVec::new( kademlia_records_count: prometheus::register(GaugeVec::new(
Opts::new( Opts::new(
"sub_libp2p_kademlia_records_count", "substrate_sub_libp2p_kademlia_records_count",
"Number of records in the Kademlia records store" "Number of records in the Kademlia records store"
), ),
&["protocol"] &["protocol"]
)?, registry)?, )?, registry)?,
kademlia_records_sizes_total: prometheus::register(GaugeVec::new( kademlia_records_sizes_total: prometheus::register(GaugeVec::new(
Opts::new( Opts::new(
"sub_libp2p_kademlia_records_sizes_total", "substrate_sub_libp2p_kademlia_records_sizes_total",
"Total size of all the records in the Kademlia records store" "Total size of all the records in the Kademlia records store"
), ),
&["protocol"] &["protocol"]
)?, registry)?, )?, registry)?,
kbuckets_num_nodes: prometheus::register(GaugeVec::new( kbuckets_num_nodes: prometheus::register(GaugeVec::new(
Opts::new( Opts::new(
"sub_libp2p_kbuckets_num_nodes", "substrate_sub_libp2p_kbuckets_num_nodes",
"Number of nodes per kbucket per Kademlia instance" "Number of nodes per kbucket per Kademlia instance"
), ),
&["protocol", "lower_ilog2_bucket_bound"] &["protocol", "lower_ilog2_bucket_bound"]
)?, registry)?, )?, registry)?,
listeners_local_addresses: prometheus::register(Gauge::new( listeners_local_addresses: prometheus::register(Gauge::new(
"sub_libp2p_listeners_local_addresses", "Number of local addresses we're listening on" "substrate_sub_libp2p_listeners_local_addresses",
"Number of local addresses we're listening on"
)?, registry)?, )?, registry)?,
listeners_errors_total: prometheus::register(Counter::new( listeners_errors_total: prometheus::register(Counter::new(
"sub_libp2p_listeners_errors_total", "substrate_sub_libp2p_listeners_errors_total",
"Total number of non-fatal errors reported by a listener" "Total number of non-fatal errors reported by a listener"
)?, registry)?, )?, registry)?,
notifications_sizes: prometheus::register(HistogramVec::new( notifications_sizes: prometheus::register(HistogramVec::new(
HistogramOpts { HistogramOpts {
common_opts: Opts::new( common_opts: Opts::new(
"sub_libp2p_notifications_sizes", "substrate_sub_libp2p_notifications_sizes",
"Sizes of the notifications send to and received from all nodes" "Sizes of the notifications send to and received from all nodes"
), ),
buckets: prometheus::exponential_buckets(64.0, 4.0, 8) buckets: prometheus::exponential_buckets(64.0, 4.0, 8)
@@ -187,38 +188,40 @@ impl Metrics {
)?, registry)?, )?, registry)?,
notifications_streams_closed_total: prometheus::register(CounterVec::new( notifications_streams_closed_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_notifications_streams_closed_total", "substrate_sub_libp2p_notifications_streams_closed_total",
"Total number of notification substreams that have been closed" "Total number of notification substreams that have been closed"
), ),
&["protocol"] &["protocol"]
)?, registry)?, )?, registry)?,
notifications_streams_opened_total: prometheus::register(CounterVec::new( notifications_streams_opened_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_notifications_streams_opened_total", "substrate_sub_libp2p_notifications_streams_opened_total",
"Total number of notification substreams that have been opened" "Total number of notification substreams that have been opened"
), ),
&["protocol"] &["protocol"]
)?, registry)?, )?, registry)?,
peerset_num_discovered: prometheus::register(Gauge::new( peerset_num_discovered: prometheus::register(Gauge::new(
"sub_libp2p_peerset_num_discovered", "Number of nodes stored in the peerset manager", "substrate_sub_libp2p_peerset_num_discovered",
"Number of nodes stored in the peerset manager",
)?, registry)?, )?, registry)?,
peerset_num_requested: prometheus::register(Gauge::new( peerset_num_requested: prometheus::register(Gauge::new(
"sub_libp2p_peerset_num_requested", "Number of nodes that the peerset manager wants us to be connected to", "substrate_sub_libp2p_peerset_num_requested",
"Number of nodes that the peerset manager wants us to be connected to",
)?, registry)?, )?, registry)?,
pending_connections: prometheus::register(Gauge::new( pending_connections: prometheus::register(Gauge::new(
"sub_libp2p_pending_connections", "substrate_sub_libp2p_pending_connections",
"Number of connections in the process of being established", "Number of connections in the process of being established",
)?, registry)?, )?, registry)?,
pending_connections_errors_total: prometheus::register(CounterVec::new( pending_connections_errors_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_pending_connections_errors_total", "substrate_sub_libp2p_pending_connections_errors_total",
"Total number of pending connection errors" "Total number of pending connection errors"
), ),
&["reason"] &["reason"]
)?, registry)?, )?, registry)?,
requests_in_failure_total: prometheus::register(CounterVec::new( requests_in_failure_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_requests_in_failure_total", "substrate_sub_libp2p_requests_in_failure_total",
"Total number of incoming requests that the node has failed to answer" "Total number of incoming requests that the node has failed to answer"
), ),
&["protocol", "reason"] &["protocol", "reason"]
@@ -226,7 +229,7 @@ impl Metrics {
requests_in_success_total: prometheus::register(HistogramVec::new( requests_in_success_total: prometheus::register(HistogramVec::new(
HistogramOpts { HistogramOpts {
common_opts: Opts::new( common_opts: Opts::new(
"sub_libp2p_requests_in_success_total", "substrate_sub_libp2p_requests_in_success_total",
"For successful incoming requests, time between receiving the request and \ "For successful incoming requests, time between receiving the request and \
starting to send the response" starting to send the response"
), ),
@@ -237,7 +240,7 @@ impl Metrics {
)?, registry)?, )?, registry)?,
requests_out_failure_total: prometheus::register(CounterVec::new( requests_out_failure_total: prometheus::register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_requests_out_failure_total", "substrate_sub_libp2p_requests_out_failure_total",
"Total number of requests that have failed" "Total number of requests that have failed"
), ),
&["protocol", "reason"] &["protocol", "reason"]
@@ -245,7 +248,7 @@ impl Metrics {
requests_out_success_total: prometheus::register(HistogramVec::new( requests_out_success_total: prometheus::register(HistogramVec::new(
HistogramOpts { HistogramOpts {
common_opts: Opts::new( common_opts: Opts::new(
"sub_libp2p_requests_out_success_total", "substrate_sub_libp2p_requests_out_success_total",
"For successful outgoing requests, time between a request's start and finish" "For successful outgoing requests, time between a request's start and finish"
), ),
buckets: prometheus::exponential_buckets(0.001, 2.0, 16) buckets: prometheus::exponential_buckets(0.001, 2.0, 16)
@@ -267,7 +270,7 @@ impl BandwidthCounters {
fn register(registry: &Registry, sinks: Arc<BandwidthSinks>) -> Result<(), PrometheusError> { fn register(registry: &Registry, sinks: Arc<BandwidthSinks>) -> Result<(), PrometheusError> {
prometheus::register( prometheus::register(
SourcedCounter::new( SourcedCounter::new(
&Opts::new("sub_libp2p_network_bytes_total", "Total bandwidth usage") &Opts::new("substrate_sub_libp2p_network_bytes_total", "Total bandwidth usage")
.variable_label("direction"), .variable_label("direction"),
BandwidthCounters(sinks), BandwidthCounters(sinks),
)?, )?,
@@ -298,7 +301,7 @@ impl MajorSyncingGauge {
prometheus::register( prometheus::register(
SourcedGauge::new( SourcedGauge::new(
&Opts::new( &Opts::new(
"sub_libp2p_is_major_syncing", "substrate_sub_libp2p_is_major_syncing",
"Whether the node is performing a major sync or not.", "Whether the node is performing a major sync or not.",
), ),
MajorSyncingGauge(value), MajorSyncingGauge(value),
@@ -328,7 +331,7 @@ impl NumConnectedGauge {
fn register(registry: &Registry, value: Arc<AtomicUsize>) -> Result<(), PrometheusError> { fn register(registry: &Registry, value: Arc<AtomicUsize>) -> Result<(), PrometheusError> {
prometheus::register( prometheus::register(
SourcedGauge::new( SourcedGauge::new(
&Opts::new("sub_libp2p_peers_count", "Number of connected peers"), &Opts::new("substrate_sub_libp2p_peers_count", "Number of connected peers"),
NumConnectedGauge(value), NumConnectedGauge(value),
)?, )?,
registry, registry,
@@ -192,7 +192,7 @@ impl Metrics {
Ok(Self { Ok(Self {
events_total: register(CounterVec::new( events_total: register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_out_events_events_total", "substrate_sub_libp2p_out_events_events_total",
"Number of broadcast network events that have been sent or received across all \ "Number of broadcast network events that have been sent or received across all \
channels" channels"
), ),
@@ -200,7 +200,7 @@ impl Metrics {
)?, registry)?, )?, registry)?,
notifications_sizes: register(CounterVec::new( notifications_sizes: register(CounterVec::new(
Opts::new( Opts::new(
"sub_libp2p_out_events_notifications_sizes", "substrate_sub_libp2p_out_events_notifications_sizes",
"Size of notification events that have been sent or received across all \ "Size of notification events that have been sent or received across all \
channels" channels"
), ),
@@ -208,7 +208,7 @@ impl Metrics {
)?, registry)?, )?, registry)?,
num_channels: register(GaugeVec::new( num_channels: register(GaugeVec::new(
Opts::new( Opts::new(
"sub_libp2p_out_events_num_channels", "substrate_sub_libp2p_out_events_num_channels",
"Number of internal active channels that broadcast network events", "Number of internal active channels that broadcast network events",
), ),
&["name"] &["name"]
+1 -1
View File
@@ -95,7 +95,7 @@ impl Metrics {
Ok(Self { Ok(Self {
propagated_transactions: register( propagated_transactions: register(
Counter::new( Counter::new(
"sync_propagated_transactions", "substrate_sync_propagated_transactions",
"Number of transactions propagated to at least one peer", "Number of transactions propagated to at least one peer",
)?, )?,
r, r,
+2 -2
View File
@@ -56,14 +56,14 @@ impl Metrics {
Ok(Self { Ok(Self {
block_constructed: register( block_constructed: register(
Histogram::with_opts(HistogramOpts::new( Histogram::with_opts(HistogramOpts::new(
"proposer_block_constructed", "substrate_proposer_block_constructed",
"Histogram of time taken to construct new block", "Histogram of time taken to construct new block",
))?, ))?,
registry, registry,
)?, )?,
number_of_transactions: register( number_of_transactions: register(
Gauge::new( Gauge::new(
"proposer_number_of_transactions", "substrate_proposer_number_of_transactions",
"Number of transactions included in block", "Number of transactions included in block",
)?, )?,
registry, registry,
+2 -2
View File
@@ -90,7 +90,7 @@ impl ServerMetrics {
Ok(Self { Ok(Self {
session_opened: register( session_opened: register(
Counter::new( Counter::new(
"rpc_sessions_opened", "substrate_rpc_sessions_opened",
"Number of persistent RPC sessions opened", "Number of persistent RPC sessions opened",
)?, )?,
r, r,
@@ -98,7 +98,7 @@ impl ServerMetrics {
.into(), .into(),
session_closed: register( session_closed: register(
Counter::new( Counter::new(
"rpc_sessions_closed", "substrate_rpc_sessions_closed",
"Number of persistent RPC sessions closed", "Number of persistent RPC sessions closed",
)?, )?,
r, r,
@@ -48,7 +48,7 @@ impl RpcMetrics {
requests_started: register( requests_started: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"rpc_requests_started", "substrate_rpc_requests_started",
"Number of RPC requests (not calls) received by the server.", "Number of RPC requests (not calls) received by the server.",
), ),
&["protocol"], &["protocol"],
@@ -58,7 +58,7 @@ impl RpcMetrics {
requests_finished: register( requests_finished: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"rpc_requests_finished", "substrate_rpc_requests_finished",
"Number of RPC requests (not calls) processed by the server.", "Number of RPC requests (not calls) processed by the server.",
), ),
&["protocol"], &["protocol"],
@@ -68,7 +68,7 @@ impl RpcMetrics {
calls_time: register( calls_time: register(
HistogramVec::new( HistogramVec::new(
HistogramOpts::new( HistogramOpts::new(
"rpc_calls_time", "substrate_rpc_calls_time",
"Total time [μs] of processed RPC calls", "Total time [μs] of processed RPC calls",
), ),
&["protocol", "method"], &["protocol", "method"],
@@ -78,7 +78,7 @@ impl RpcMetrics {
calls_started: register( calls_started: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"rpc_calls_started", "substrate_rpc_calls_started",
"Number of received RPC calls (unique un-batched requests)", "Number of received RPC calls (unique un-batched requests)",
), ),
&["protocol", "method"], &["protocol", "method"],
@@ -88,7 +88,7 @@ impl RpcMetrics {
calls_finished: register( calls_finished: register(
CounterVec::new( CounterVec::new(
Opts::new( Opts::new(
"rpc_calls_finished", "substrate_rpc_calls_finished",
"Number of processed RPC calls (unique un-batched requests)", "Number of processed RPC calls (unique un-batched requests)",
), ),
&["protocol", "method", "is_error"], &["protocol", "method", "is_error"],
+4 -3
View File
@@ -36,7 +36,7 @@ pub use sc_telemetry::TelemetryEndpoints;
pub use sc_transaction_pool::Options as TransactionPoolOptions; pub use sc_transaction_pool::Options as TransactionPoolOptions;
use sp_core::crypto::SecretString; use sp_core::crypto::SecretString;
use std::{ use std::{
io, io, iter,
net::SocketAddr, net::SocketAddr,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
@@ -188,10 +188,11 @@ impl PrometheusConfig {
/// Create a new config using the default registry. /// Create a new config using the default registry.
/// ///
/// The default registry prefixes metrics with `substrate`. /// The default registry prefixes metrics with `substrate`.
pub fn new_with_default_registry(port: SocketAddr) -> Self { pub fn new_with_default_registry(port: SocketAddr, chain_id: String) -> Self {
let param = iter::once((String::from("chain"), chain_id)).collect();
Self { Self {
port, port,
registry: Registry::new_custom(Some("substrate".into()), None) registry: Registry::new_custom(None, Some(param))
.expect("this can only fail if the prefix is empty"), .expect("this can only fail if the prefix is empty"),
} }
} }
+13 -10
View File
@@ -55,7 +55,7 @@ impl PrometheusMetrics {
register( register(
Gauge::<U64>::with_opts( Gauge::<U64>::with_opts(
Opts::new( Opts::new(
"build_info", "substrate_build_info",
"A metric with a constant '1' value labeled by name, version", "A metric with a constant '1' value labeled by name, version",
) )
.const_label("name", name) .const_label("name", name)
@@ -65,8 +65,11 @@ impl PrometheusMetrics {
)? )?
.set(1); .set(1);
register(Gauge::<U64>::new("node_roles", "The roles the node is running as")?, &registry)? register(
.set(roles); Gauge::<U64>::new("substrate_node_roles", "The roles the node is running as")?,
&registry,
)?
.set(roles);
register_globals(registry)?; register_globals(registry)?;
@@ -74,7 +77,7 @@ impl PrometheusMetrics {
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap_or_default(); SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap_or_default();
register( register(
Gauge::<U64>::new( Gauge::<U64>::new(
"process_start_time_seconds", "substrate_process_start_time_seconds",
"Number of seconds between the UNIX epoch and the moment the process started", "Number of seconds between the UNIX epoch and the moment the process started",
)?, )?,
registry, registry,
@@ -85,20 +88,20 @@ impl PrometheusMetrics {
// generic internals // generic internals
block_height: register( block_height: register(
GaugeVec::new( GaugeVec::new(
Opts::new("block_height", "Block height info of the chain"), Opts::new("substrate_block_height", "Block height info of the chain"),
&["status"], &["status"],
)?, )?,
registry, registry,
)?, )?,
number_leaves: register( number_leaves: register(
Gauge::new("number_leaves", "Number of known chain leaves (aka forks)")?, Gauge::new("substrate_number_leaves", "Number of known chain leaves (aka forks)")?,
registry, registry,
)?, )?,
ready_transactions_number: register( ready_transactions_number: register(
Gauge::new( Gauge::new(
"ready_transactions_number", "substrate_ready_transactions_number",
"Number of transactions in the ready queue", "Number of transactions in the ready queue",
)?, )?,
registry, registry,
@@ -106,16 +109,16 @@ impl PrometheusMetrics {
// I/ O // I/ O
database_cache: register( database_cache: register(
Gauge::new("database_cache_bytes", "RocksDB cache size in bytes")?, Gauge::new("substrate_database_cache_bytes", "RocksDB cache size in bytes")?,
registry, registry,
)?, )?,
state_cache: register( state_cache: register(
Gauge::new("state_cache_bytes", "State cache size in bytes")?, Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
registry, registry,
)?, )?,
state_db: register( state_db: register(
GaugeVec::new( GaugeVec::new(
Opts::new("state_db_cache_bytes", "State DB cache in bytes"), Opts::new("substrate_state_db_cache_bytes", "State DB cache in bytes"),
&["subtype"], &["subtype"],
)?, )?,
registry, registry,
@@ -401,7 +401,7 @@ impl Metrics {
poll_duration: register(HistogramVec::new( poll_duration: register(HistogramVec::new(
HistogramOpts { HistogramOpts {
common_opts: Opts::new( common_opts: Opts::new(
"tasks_polling_duration", "substrate_tasks_polling_duration",
"Duration in seconds of each invocation of Future::poll" "Duration in seconds of each invocation of Future::poll"
), ),
buckets: exponential_buckets(0.001, 4.0, 9) buckets: exponential_buckets(0.001, 4.0, 9)
@@ -411,21 +411,21 @@ impl Metrics {
)?, registry)?, )?, registry)?,
poll_start: register(CounterVec::new( poll_start: register(CounterVec::new(
Opts::new( Opts::new(
"tasks_polling_started_total", "substrate_tasks_polling_started_total",
"Total number of times we started invoking Future::poll" "Total number of times we started invoking Future::poll"
), ),
&["task_name", "task_group"] &["task_name", "task_group"]
)?, registry)?, )?, registry)?,
tasks_spawned: register(CounterVec::new( tasks_spawned: register(CounterVec::new(
Opts::new( Opts::new(
"tasks_spawned_total", "substrate_tasks_spawned_total",
"Total number of tasks that have been spawned on the Service" "Total number of tasks that have been spawned on the Service"
), ),
&["task_name", "task_group"] &["task_name", "task_group"]
)?, registry)?, )?, registry)?,
tasks_ended: register(CounterVec::new( tasks_ended: register(CounterVec::new(
Opts::new( Opts::new(
"tasks_ended_total", "substrate_tasks_ended_total",
"Total number of tasks for which Future::poll has returned Ready(()) or panicked" "Total number of tasks for which Future::poll has returned Ready(()) or panicked"
), ),
&["task_name", "reason", "task_group"] &["task_name", "reason", "task_group"]
@@ -56,28 +56,28 @@ impl Metrics {
Ok(Self { Ok(Self {
submitted_transactions: register( submitted_transactions: register(
Counter::new( Counter::new(
"sub_txpool_submitted_transactions", "substrate_sub_txpool_submitted_transactions",
"Total number of transactions submitted", "Total number of transactions submitted",
)?, )?,
registry, registry,
)?, )?,
validations_invalid: register( validations_invalid: register(
Counter::new( Counter::new(
"sub_txpool_validations_invalid", "substrate_sub_txpool_validations_invalid",
"Total number of transactions that were removed from the pool as invalid", "Total number of transactions that were removed from the pool as invalid",
)?, )?,
registry, registry,
)?, )?,
block_transactions_pruned: register( block_transactions_pruned: register(
Counter::new( Counter::new(
"sub_txpool_block_transactions_pruned", "substrate_sub_txpool_block_transactions_pruned",
"Total number of transactions that was requested to be pruned by block events", "Total number of transactions that was requested to be pruned by block events",
)?, )?,
registry, registry,
)?, )?,
block_transactions_resubmitted: register( block_transactions_resubmitted: register(
Counter::new( Counter::new(
"sub_txpool_block_transactions_resubmitted", "substrate_sub_txpool_block_transactions_resubmitted",
"Total number of transactions that was requested to be resubmitted by block events", "Total number of transactions that was requested to be resubmitted by block events",
)?, )?,
registry, registry,
@@ -98,14 +98,14 @@ impl ApiMetrics {
Ok(Self { Ok(Self {
validations_scheduled: register( validations_scheduled: register(
Counter::new( Counter::new(
"sub_txpool_validations_scheduled", "substrate_sub_txpool_validations_scheduled",
"Total number of transactions scheduled for validation", "Total number of transactions scheduled for validation",
)?, )?,
registry, registry,
)?, )?,
validations_finished: register( validations_finished: register(
Counter::new( Counter::new(
"sub_txpool_validations_finished", "substrate_sub_txpool_validations_finished",
"Total number of transactions that finished validation", "Total number of transactions that finished validation",
)?, )?,
registry, registry,
+3 -3
View File
@@ -29,17 +29,17 @@ use prometheus::{core::GenericCounterVec, Opts};
lazy_static! { lazy_static! {
pub static ref TOKIO_THREADS_TOTAL: GenericCounter<AtomicU64> = pub static ref TOKIO_THREADS_TOTAL: GenericCounter<AtomicU64> =
GenericCounter::new("tokio_threads_total", "Total number of threads created") GenericCounter::new("substrate_tokio_threads_total", "Total number of threads created")
.expect("Creating of statics doesn't fail. qed"); .expect("Creating of statics doesn't fail. qed");
pub static ref TOKIO_THREADS_ALIVE: GenericGauge<AtomicU64> = pub static ref TOKIO_THREADS_ALIVE: GenericGauge<AtomicU64> =
GenericGauge::new("tokio_threads_alive", "Number of threads alive right now") GenericGauge::new("substrate_tokio_threads_alive", "Number of threads alive right now")
.expect("Creating of statics doesn't fail. qed"); .expect("Creating of statics doesn't fail. qed");
} }
#[cfg(feature = "metered")] #[cfg(feature = "metered")]
lazy_static! { lazy_static! {
pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec<AtomicU64> = GenericCounterVec::new( pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec<AtomicU64> = GenericCounterVec::new(
Opts::new("unbounded_channel_len", "Items in each mpsc::unbounded instance"), Opts::new("substrate_unbounded_channel_len", "Items in each mpsc::unbounded instance"),
&["entity", "action"] // 'name of channel, send|received|dropped &["entity", "action"] // 'name of channel, send|received|dropped
).expect("Creating of statics doesn't fail. qed"); ).expect("Creating of statics doesn't fail. qed");