2023-02-23 17:52:02 -06:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2024-01-05 10:08:38 -06:00
|
|
|
"github.com/grafana/dskit/instrument"
|
2023-02-23 17:52:02 -06:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Historian struct {
|
2023-03-06 10:40:37 -06:00
|
|
|
Info *prometheus.GaugeVec
|
|
|
|
TransitionsTotal *prometheus.CounterVec
|
|
|
|
TransitionsFailed *prometheus.CounterVec
|
|
|
|
WritesTotal *prometheus.CounterVec
|
|
|
|
WritesFailed *prometheus.CounterVec
|
|
|
|
WriteDuration *instrument.HistogramCollector
|
|
|
|
BytesWritten prometheus.Counter
|
2023-02-23 17:52:02 -06:00
|
|
|
}
|
|
|
|
|
2023-11-27 08:20:50 -06:00
|
|
|
func NewHistorianMetrics(r prometheus.Registerer, subsystem string) *Historian {
|
2023-02-23 17:52:02 -06:00
|
|
|
return &Historian{
|
2023-03-06 10:40:37 -06:00
|
|
|
Info: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_info",
|
|
|
|
Help: "Information about the state history store.",
|
|
|
|
}, []string{"backend"}),
|
|
|
|
TransitionsTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_transitions_total",
|
|
|
|
Help: "The total number of state transitions processed.",
|
|
|
|
}, []string{"org"}),
|
|
|
|
TransitionsFailed: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_transitions_failed_total",
|
|
|
|
Help: "The total number of state transitions that failed to be written - they are not retried.",
|
|
|
|
}, []string{"org"}),
|
|
|
|
WritesTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_writes_total",
|
|
|
|
Help: "The total number of state history batches that were attempted to be written.",
|
2023-03-28 08:49:51 -05:00
|
|
|
}, []string{"org", "backend"}),
|
2023-03-06 10:40:37 -06:00
|
|
|
WritesFailed: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_writes_failed_total",
|
|
|
|
Help: "The total number of failed writes of state history batches.",
|
2023-03-28 08:49:51 -05:00
|
|
|
}, []string{"org", "backend"}),
|
2023-02-23 17:52:02 -06:00
|
|
|
WriteDuration: instrument.NewHistogramCollector(promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-02-23 17:52:02 -06:00
|
|
|
Name: "state_history_request_duration_seconds",
|
2023-03-06 10:40:37 -06:00
|
|
|
Help: "Histogram of request durations to the state history store. Only valid when using external stores.",
|
2023-02-23 17:52:02 -06:00
|
|
|
Buckets: instrument.DefBuckets,
|
|
|
|
}, instrument.HistogramCollectorBuckets)),
|
2023-03-06 10:40:37 -06:00
|
|
|
BytesWritten: promauto.With(r).NewCounter(prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
2023-11-27 08:20:50 -06:00
|
|
|
Subsystem: subsystem,
|
2023-03-06 10:40:37 -06:00
|
|
|
Name: "state_history_writes_bytes_total",
|
|
|
|
Help: "The total number of bytes sent within a batch to the state history store. Only valid when using the Loki store.",
|
|
|
|
}),
|
2023-02-23 17:52:02 -06:00
|
|
|
}
|
|
|
|
}
|