Skip to content

Commit

Permalink
metrics/ir: neofs_ir_state_health metric
Browse files Browse the repository at this point in the history
Expose health status via Prometheus.

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Sep 11, 2024
1 parent 3835864 commit f16d6d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changelog for NeoFS Node

### Added
- More effective FSTree writer for HDDs, new configuration options for it (#2814)
- New health status `CREATE_SERVER` in inner ring (#2934)
- Expose health status of inner ring via Prometheus (#2934)

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions pkg/innerring/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check warning on line 205 in pkg/innerring/state.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/state.go#L204-L205

Added lines #L204 - L205 were not covered by tests
}
}

// HealthStatus returns the current health status of the IR application.
Expand Down
18 changes: 16 additions & 2 deletions pkg/metrics/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,12 +24,25 @@ 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,
}
}

// SetEpoch updates epoch metrics.
func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
m.epoch.Set(float64(epoch))
}

func (m InnerRingServiceMetrics) SetHealthCheck(healthCheck int32) {
m.healthCheck.Set(float64(healthCheck))

Check warning on line 47 in pkg/metrics/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/metrics/innerring.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}

0 comments on commit f16d6d6

Please sign in to comment.