diff --git a/src/config.rs b/src/config.rs index cc3e76a..f78a32c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -45,6 +45,8 @@ pub(crate) struct PingConfig { #[serde_as(as = "DurationMilliSeconds")] #[serde(default = "default_timeout")] pub(crate) timeout: Duration, + #[serde(default = "default_buckets")] + pub(crate) bucket_sizes: Vec, pub(crate) hosts: HashMap, } @@ -52,6 +54,14 @@ fn default_timeout() -> Duration { Duration::from_secs(3) } +fn default_buckets() -> Vec { + vec![ + 0.5, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 50.0, 75.0, 100.0, 150.0, 200.0, 250.0, 300.0, + 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 900.0, 1000.0, + 1250.0, 1500.0, 1750.0, 2000.0, + ] +} + #[derive(Deserialize, Clone)] pub(crate) struct LogConfig { pub(crate) level: log::LevelFilter, @@ -117,11 +127,10 @@ pub(crate) fn setup_app() -> Result { pub(crate) fn setup_prometheus(config: &Config) -> Result { let handle = PrometheusBuilder::new() - .set_buckets_for_metric(Matcher::Full("ping_rtt_milliseconds".into()), &vec![ - 0.5, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 50.0, 75.0, 100.0, 150.0, 200.0, 250.0, 300.0, - 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 900.0, 1000.0, - 1250.0, 1500.0, 1750.0, 2000.0, - ])? + .set_buckets_for_metric( + Matcher::Full("ping_rtt_milliseconds".into()), + &config.ping.bucket_sizes, + )? .install_recorder()?; for target in config.ping.hosts.keys() {