diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index e49e29f3f9..7eda9bfe8a 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -274,6 +274,9 @@ fn run( // Allow Prometheus to export the time at which the process was started. metrics::expose_process_start_time(&log); + // Allow Prometheus access to the version and commit of the Lighthouse build. + metrics::expose_lighthouse_version(); + if matches.is_present("spec") { warn!( log, diff --git a/lighthouse/src/metrics.rs b/lighthouse/src/metrics.rs index ac880602f3..ef3c33d298 100644 --- a/lighthouse/src/metrics.rs +++ b/lighthouse/src/metrics.rs @@ -1,5 +1,6 @@ use lazy_static::lazy_static; pub use lighthouse_metrics::*; +use lighthouse_version::VERSION; use slog::{error, Logger}; use std::time::{SystemTime, UNIX_EPOCH}; @@ -10,6 +11,14 @@ lazy_static! { ); } +lazy_static! { + pub static ref LIGHTHOUSE_VERSION: Result = try_create_int_gauge_vec( + "lighthouse_info", + "The build of Lighthouse running on the server", + &["version"], + ); +} + pub fn expose_process_start_time(log: &Logger) { match SystemTime::now().duration_since(UNIX_EPOCH) { Ok(duration) => set_gauge(&PROCESS_START_TIME_SECONDS, duration.as_secs() as i64), @@ -20,3 +29,7 @@ pub fn expose_process_start_time(log: &Logger) { ), } } + +pub fn expose_lighthouse_version() { + set_gauge_vec(&LIGHTHOUSE_VERSION, &[VERSION], 1); +}