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)) +}