Add Lighthouse version and commit hash to Prometheus metrics (#2427)
## Issue Addressed #2225 ## Proposed Changes Exposes the version given from the `lighthouse_version` crate to the Prometheus metrics server. ## Additional Info - This metric appears in both the Beacon Node and Validator Client metrics servers. - This is the simplest solution. It might be better to include the version and commit hash as separate labels rather than combined, however this would be more involved. Happy to do it that way if this is too cumbersome to use. - The metric appears as: ``` # HELP lighthouse_info The build of Lighthouse running on the server # TYPE lighthouse_info gauge lighthouse_info{version="Lighthouse/v1.4.0-379664a+"} 1 ```
This commit is contained in:
parent
379664a648
commit
206486006c
@ -274,6 +274,9 @@ fn run<E: EthSpec>(
|
||||
// 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,
|
||||
|
@ -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<IntGaugeVec> = 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user