From 87d06d6752a60ee7618f99bcb5acb43dd7e14386 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Wed, 25 Sep 2024 17:42:02 +0100 Subject: [PATCH 1/2] Add process_start_time_seconds metric. --- CHANGELOG.md | 1 + crates/pathfinder/src/bin/pathfinder/main.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a394752189..657f2430f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pathfinder now fetches data concurrently from the feeder gateway when catching up. The `--gateway.fetch-concurrency` CLI option can be used to limit how many blocks are fetched concurrently (the default is 8). - `--disable-version-update-check` CLI option has been added to disable the periodic checking for a new version. +- add `process_start_time_seconds` metric showing the unix timestamp when the process started. ### Changed diff --git a/crates/pathfinder/src/bin/pathfinder/main.rs b/crates/pathfinder/src/bin/pathfinder/main.rs index 6ad4a4651a..1145cecba4 100644 --- a/crates/pathfinder/src/bin/pathfinder/main.rs +++ b/crates/pathfinder/src/bin/pathfinder/main.rs @@ -5,6 +5,7 @@ use std::num::NonZeroU32; use std::path::PathBuf; use std::sync::atomic::AtomicBool; use std::sync::Arc; +use std::time::{SystemTime, UNIX_EPOCH}; use anyhow::Context; use metrics_exporter_prometheus::PrometheusBuilder; @@ -642,6 +643,11 @@ async fn spawn_monitoring( metrics::gauge!("pathfinder_build_info", 1.0, "version" => VERGEN_GIT_DESCRIBE); + match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(duration) => metrics::gauge!("process_start_time_seconds", duration.as_secs() as f64), + Err(err) => tracing::error!("Failed to read system time: {:?}", err), + } + let (_, handle) = monitoring::spawn_server(address, readiness, sync_state, prometheus_handle).await?; Ok(handle) From fb30f35c23becfd4d4cc9e13e1a23aa28e5498da Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Thu, 26 Sep 2024 16:00:58 +0100 Subject: [PATCH 2/2] Add metric to README. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7a6cf5ad86..e1b7945592 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,10 @@ This endpoint is useful for Docker nodes which only want to present themselves a `/metrics` provides a [Prometheus](https://prometheus.io/) metrics scrape endpoint. Currently the following metrics are available: +#### Process metrics + +- `process_start_time_seconds` provides the unix timestamp at which pathfinder started + #### RPC related counters - `rpc_method_calls_total`,