Skip to main content

reth_node_core/args/
metric.rs

1use clap::Parser;
2use reth_cli_util::{parse_duration_from_secs, parse_socket_address};
3use std::{net::SocketAddr, time::Duration};
4
5/// Default push gateway interval in seconds.
6const DEFAULT_PUSH_GATEWAY_INTERVAL_SECS: u64 = 5;
7
8/// Metrics configuration.
9#[derive(Debug, Clone, Parser)]
10pub struct MetricArgs {
11    /// Enable Prometheus metrics.
12    ///
13    /// The metrics will be served at the given interface and port.
14    #[arg(long="metrics", alias = "metrics.prometheus", value_name = "PROMETHEUS", value_parser = parse_socket_address, help_heading = "Metrics")]
15    pub prometheus: Option<SocketAddr>,
16
17    /// URL for pushing Prometheus metrics to a push gateway.
18    ///
19    /// If set, the node will periodically push metrics to the specified push gateway URL.
20    #[arg(
21        long = "metrics.prometheus.push.url",
22        value_name = "PUSH_GATEWAY_URL",
23        help_heading = "Metrics"
24    )]
25    pub push_gateway_url: Option<String>,
26
27    /// Interval in seconds for pushing metrics to push gateway.
28    ///
29    /// Default: 5 seconds
30    #[arg(
31        long = "metrics.prometheus.push.interval",
32        default_value = "5",
33        value_parser = parse_duration_from_secs,
34        value_name = "SECONDS",
35        help_heading = "Metrics"
36    )]
37    pub push_gateway_interval: Duration,
38}
39
40impl Default for MetricArgs {
41    fn default() -> Self {
42        Self {
43            prometheus: None,
44            push_gateway_url: None,
45            push_gateway_interval: Duration::from_secs(DEFAULT_PUSH_GATEWAY_INTERVAL_SECS),
46        }
47    }
48}