From d8a6e09c25dfce5496eed98d3e0a1f3b8adbb947 Mon Sep 17 00:00:00 2001 From: Techno Freak Date: Fri, 5 Jan 2024 15:43:52 +0300 Subject: [PATCH] feat: add start time metric --- pkg/metrics/metrics.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 2987bc8..b4e58f6 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -40,6 +40,7 @@ type Manager struct { reporterQueriesCounter *prometheus.CounterVec appVersionGauge *prometheus.GaugeVec + startTimeGauge *prometheus.GaugeVec chainInfoGauge *prometheus.GaugeVec } @@ -87,6 +88,10 @@ func NewManager(logger *zerolog.Logger, config configPkg.MetricsConfig) *Manager Name: constants.PrometheusMetricsPrefix + "version", Help: "App version", }, []string{"version"}), + startTimeGauge: promauto.NewGaugeVec(prometheus.GaugeOpts{ + Name: constants.PrometheusMetricsPrefix + "start_time", + Help: "Unix timestamp on when the app was started. Useful for annotations.", + }, []string{}), eventsTotalCounter: promauto.NewCounterVec(prometheus.CounterOpts{ Name: constants.PrometheusMetricsPrefix + "events_total", Help: "WebSocket events received by node", @@ -111,6 +116,10 @@ func NewManager(logger *zerolog.Logger, config configPkg.MetricsConfig) *Manager } func (m *Manager) SetAllDefaultMetrics(chains []*configTypes.Chain) { + m.startTimeGauge. + With(prometheus.Labels{}). + Set(float64(time.Now().Unix())) + for _, chain := range chains { m.SetDefaultMetrics(chain) }