The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/ngalert/metrics/state.go

41 lines
1.2 KiB

package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type State struct {
StateUpdateDuration prometheus.Histogram
StateFullSyncDuration prometheus.Histogram
r prometheus.Registerer
}
// Registerer exposes the Prometheus register directly. The state package needs this as, it uses a collector to fetch the current alerts by state in the system.
func (s State) Registerer() prometheus.Registerer {
return s.r
}
func NewStateMetrics(r prometheus.Registerer) *State {
return &State{
r: r,
StateUpdateDuration: promauto.With(r).NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "state_calculation_duration_seconds",
Help: "The duration of calculation of a single state.",
Buckets: []float64{0.01, 0.1, 1, 2, 5, 10},
},
),
StateFullSyncDuration: promauto.With(r).NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "state_full_sync_duration_seconds",
Help: "The duration of fully synchronizing the state with the database.",
Buckets: []float64{0.01, 0.1, 1, 2, 5, 10, 60},
},
),
}
}