From 9acfa8401db3fb1b19eebb6a1487c2dcfafcda93 Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Wed, 11 Sep 2024 20:34:32 +0300 Subject: [PATCH] metrics/ir: `neofs_ir_state_health` metric Expose health status via Prometheus. Signed-off-by: Andrey Butusov --- CHANGELOG.md | 2 ++ pkg/innerring/state.go | 3 +++ pkg/metrics/innerring.go | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f95c8924..f216e86c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Changelog for NeoFS Node ### Added - More effective FSTree writer for HDDs, new configuration options for it (#2814) +- New health statuses in inner ring (#2934) +- Expose health status of inner ring via Prometheus (#2934) ### Fixed diff --git a/pkg/innerring/state.go b/pkg/innerring/state.go index 68be14d00a..c65ece2c12 100644 --- a/pkg/innerring/state.go +++ b/pkg/innerring/state.go @@ -201,6 +201,9 @@ func (s *Server) ResetEpochTimer(h uint32) error { func (s *Server) setHealthStatus(hs control.HealthStatus) { s.healthStatus.Store(hs) + if s.metrics != nil { + s.metrics.SetHealthCheck(int32(hs)) + } } // HealthStatus returns the current health status of the IR application. diff --git a/pkg/metrics/innerring.go b/pkg/metrics/innerring.go index 9492c29170..9e7204531a 100644 --- a/pkg/metrics/innerring.go +++ b/pkg/metrics/innerring.go @@ -8,7 +8,8 @@ const innerRingNameSpace = "neofs_ir" // InnerRingServiceMetrics contains metrics collected by inner ring. type InnerRingServiceMetrics struct { - epoch prometheus.Gauge + epoch prometheus.Gauge + healthCheck prometheus.Gauge } // NewInnerRingMetrics returns new instance of metrics collectors for inner ring. @@ -23,8 +24,17 @@ func NewInnerRingMetrics(version string) InnerRingServiceMetrics { }) prometheus.MustRegister(epoch) + healthCheck := prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: innerRingNameSpace, + Subsystem: stateSubsystem, + Name: "health", + Help: "Current ir state", + }) + prometheus.MustRegister(healthCheck) + return InnerRingServiceMetrics{ - epoch: epoch, + epoch: epoch, + healthCheck: healthCheck, } } @@ -32,3 +42,7 @@ func NewInnerRingMetrics(version string) InnerRingServiceMetrics { func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) { m.epoch.Set(float64(epoch)) } + +func (m InnerRingServiceMetrics) SetHealthCheck(healthCheck int32) { + m.healthCheck.Set(float64(healthCheck)) +}