forked from TrueCloudLab/frostfs-node
[#1614] metrics: Add health metrics
Also, rename metrics structure since it collects not only storage metrics now. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
2455b72844
commit
581a9901c9
4 changed files with 40 additions and 7 deletions
|
@ -105,7 +105,7 @@ type cfg struct {
|
|||
|
||||
cfgNotifications cfgNotifications
|
||||
|
||||
metricsCollector *metrics.StorageMetrics
|
||||
metricsCollector *metrics.NodeMetrics
|
||||
|
||||
workers []worker
|
||||
|
||||
|
@ -326,7 +326,7 @@ func initCfg(path string) *cfg {
|
|||
user.IDFromKey(&c.ownerIDFromKey, key.PrivateKey.PublicKey)
|
||||
|
||||
if metricsconfig.Enabled(c.appCfg) {
|
||||
c.metricsCollector = metrics.NewStorageMetrics()
|
||||
c.metricsCollector = metrics.NewNodeMetrics()
|
||||
netState.metrics = c.metricsCollector
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ type networkState struct {
|
|||
|
||||
nodeInfo atomic.Value // *netmapSDK.NodeInfo
|
||||
|
||||
metrics *metrics.StorageMetrics
|
||||
metrics *metrics.NodeMetrics
|
||||
}
|
||||
|
||||
func newNetworkState() *networkState {
|
||||
|
|
|
@ -4,19 +4,23 @@ import "github.com/prometheus/client_golang/prometheus"
|
|||
|
||||
const namespace = "neofs_node"
|
||||
|
||||
type StorageMetrics struct {
|
||||
type NodeMetrics struct {
|
||||
objectServiceMetrics
|
||||
engineMetrics
|
||||
stateMetrics
|
||||
epoch prometheus.Gauge
|
||||
}
|
||||
|
||||
func NewStorageMetrics() *StorageMetrics {
|
||||
func NewNodeMetrics() *NodeMetrics {
|
||||
objectService := newObjectServiceMetrics()
|
||||
objectService.register()
|
||||
|
||||
engine := newEngineMetrics()
|
||||
engine.register()
|
||||
|
||||
state := newStateMetrics()
|
||||
state.register()
|
||||
|
||||
epoch := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
|
@ -25,14 +29,15 @@ func NewStorageMetrics() *StorageMetrics {
|
|||
})
|
||||
prometheus.MustRegister(epoch)
|
||||
|
||||
return &StorageMetrics{
|
||||
return &NodeMetrics{
|
||||
objectServiceMetrics: objectService,
|
||||
engineMetrics: engine,
|
||||
stateMetrics: state,
|
||||
epoch: epoch,
|
||||
}
|
||||
}
|
||||
|
||||
// SetEpoch updates epoch metric.
|
||||
func (m *StorageMetrics) SetEpoch(epoch uint64) {
|
||||
func (m *NodeMetrics) SetEpoch(epoch uint64) {
|
||||
m.epoch.Set(float64(epoch))
|
||||
}
|
||||
|
|
28
pkg/metrics/state.go
Normal file
28
pkg/metrics/state.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package metrics
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
const stateSubsystem = "state"
|
||||
|
||||
type stateMetrics struct {
|
||||
healthCheck prometheus.Gauge
|
||||
}
|
||||
|
||||
func newStateMetrics() stateMetrics {
|
||||
return stateMetrics{
|
||||
healthCheck: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: stateSubsystem,
|
||||
Name: "health",
|
||||
Help: "Current Node state",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m stateMetrics) register() {
|
||||
prometheus.MustRegister(m.healthCheck)
|
||||
}
|
||||
|
||||
func (m stateMetrics) SetHealth(s int32) {
|
||||
m.healthCheck.Set(float64(s))
|
||||
}
|
Loading…
Reference in a new issue