forked from TrueCloudLab/frostfs-http-gw
[#194] Use gauge instead of counter for metrics
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
4348f7253a
commit
e0ab929410
1 changed files with 14 additions and 12 deletions
|
@ -42,9 +42,9 @@ type stateMetrics struct {
|
||||||
|
|
||||||
type poolMetricsCollector struct {
|
type poolMetricsCollector struct {
|
||||||
pool *pool.Pool
|
pool *pool.Pool
|
||||||
overallErrors prometheus.Counter
|
overallErrors prometheus.Gauge
|
||||||
overallNodeErrors *prometheus.CounterVec
|
overallNodeErrors *prometheus.GaugeVec
|
||||||
overallNodeRequests *prometheus.CounterVec
|
overallNodeRequests *prometheus.GaugeVec
|
||||||
currentErrors *prometheus.GaugeVec
|
currentErrors *prometheus.GaugeVec
|
||||||
requestDuration *prometheus.GaugeVec
|
requestDuration *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ func (m stateMetrics) SetHealth(s int32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPoolMetricsCollector(p *pool.Pool) *poolMetricsCollector {
|
func newPoolMetricsCollector(p *pool.Pool) *poolMetricsCollector {
|
||||||
overallErrors := prometheus.NewCounter(
|
overallErrors := prometheus.NewGauge(
|
||||||
prometheus.CounterOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: poolSubsystem,
|
Subsystem: poolSubsystem,
|
||||||
Name: "overall_errors",
|
Name: "overall_errors",
|
||||||
|
@ -92,8 +92,8 @@ func newPoolMetricsCollector(p *pool.Pool) *poolMetricsCollector {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
overallNodeErrors := prometheus.NewCounterVec(
|
overallNodeErrors := prometheus.NewGaugeVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: poolSubsystem,
|
Subsystem: poolSubsystem,
|
||||||
Name: "overall_node_errors",
|
Name: "overall_node_errors",
|
||||||
|
@ -104,8 +104,8 @@ func newPoolMetricsCollector(p *pool.Pool) *poolMetricsCollector {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
overallNodeRequests := prometheus.NewCounterVec(
|
overallNodeRequests := prometheus.NewGaugeVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: poolSubsystem,
|
Subsystem: poolSubsystem,
|
||||||
Name: "overall_node_requests",
|
Name: "overall_node_requests",
|
||||||
|
@ -175,18 +175,20 @@ func (m *poolMetricsCollector) register() {
|
||||||
func (m *poolMetricsCollector) updateStatistic() {
|
func (m *poolMetricsCollector) updateStatistic() {
|
||||||
stat := m.pool.Statistic()
|
stat := m.pool.Statistic()
|
||||||
|
|
||||||
|
m.overallNodeErrors.Reset()
|
||||||
|
m.overallNodeRequests.Reset()
|
||||||
m.currentErrors.Reset()
|
m.currentErrors.Reset()
|
||||||
m.requestDuration.Reset()
|
m.requestDuration.Reset()
|
||||||
|
|
||||||
for _, node := range stat.Nodes() {
|
for _, node := range stat.Nodes() {
|
||||||
m.overallNodeErrors.WithLabelValues(node.Address()).Add(float64(node.OverallErrors()))
|
m.overallNodeErrors.WithLabelValues(node.Address()).Set(float64(node.OverallErrors()))
|
||||||
m.overallNodeRequests.WithLabelValues(node.Address()).Add(float64(node.Requests()))
|
m.overallNodeRequests.WithLabelValues(node.Address()).Set(float64(node.Requests()))
|
||||||
|
|
||||||
m.currentErrors.WithLabelValues(node.Address()).Set(float64(node.CurrentErrors()))
|
m.currentErrors.WithLabelValues(node.Address()).Set(float64(node.CurrentErrors()))
|
||||||
m.updateRequestsDuration(node)
|
m.updateRequestsDuration(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.overallErrors.Add(float64(stat.OverallErrors()))
|
m.overallErrors.Set(float64(stat.OverallErrors()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *poolMetricsCollector) updateRequestsDuration(node pool.NodeStatistic) {
|
func (m *poolMetricsCollector) updateRequestsDuration(node pool.NodeStatistic) {
|
||||||
|
|
Loading…
Reference in a new issue