[#2022] Add metric readonly to get shards mode

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2022-12-09 16:52:13 +03:00 committed by Anton Nikiforov
parent e5c304536b
commit edb1428248
7 changed files with 59 additions and 3 deletions

View file

@ -35,7 +35,8 @@ type (
putPayload prometheus.Counter
getPayload prometheus.Counter
shardMetrics *prometheus.GaugeVec
shardMetrics *prometheus.GaugeVec
shardsReadonly *prometheus.GaugeVec
}
)
@ -158,6 +159,15 @@ func newObjectServiceMetrics() objectServiceMetrics {
},
[]string{shardIDLabelKey, counterTypeLabelKey},
)
shardsReadonly = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: objectSubsystem,
Name: "readonly",
Help: "Shard state",
},
[]string{shardIDLabelKey},
)
)
return objectServiceMetrics{
@ -178,6 +188,7 @@ func newObjectServiceMetrics() objectServiceMetrics {
putPayload: putPayload,
getPayload: getPayload,
shardMetrics: shardsMetrics,
shardsReadonly: shardsReadonly,
}
}
@ -202,6 +213,7 @@ func (m objectServiceMetrics) register() {
prometheus.MustRegister(m.getPayload)
prometheus.MustRegister(m.shardMetrics)
prometheus.MustRegister(m.shardsReadonly)
}
func (m objectServiceMetrics) IncGetReqCounter(success bool) {
@ -285,3 +297,15 @@ func (m objectServiceMetrics) SetObjectCounter(shardID, objectType string, v uin
},
).Set(float64(v))
}
func (m objectServiceMetrics) SetReadonly(shardID string, readonly bool) {
var flag float64
if readonly {
flag = 1
}
m.shardsReadonly.With(
prometheus.Labels{
shardIDLabelKey: shardID,
},
).Set(flag)
}