mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 10:24:54 -06:00
* Alerting: Add metrics to the remote Alertmanager struct * rephrase http_requests_failed description * make linter happy * remove unnecessary metrics * extract timed client to separate package * use histogram collector from dskit * remove weaveworks dependency * capture metrics for all requests to the remote Alertmanager (both clients) * use the timed client in the MimirAuthRoundTripper * HTTPRequestsDuration -> HTTPRequestDuration, clean up mimir client factory function * refactor * less git diff * gauge for last readiness check in seconds * initialize LastReadinesCheck to 0, tweak metric names and descriptions * add counters for sync attempts/errors * last config sync and last state sync timestamps (gauges) * change latency metric name * metric for remote Alertmanager mode * code review comments * move label constants to metrics package
72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
const (
|
|
GrafanaBackend = "grafana"
|
|
ProxyBackend = "proxy"
|
|
Namespace = "grafana"
|
|
Subsystem = "alerting"
|
|
)
|
|
|
|
// ProvideService is a Metrics factory.
|
|
func ProvideService() *NGAlert {
|
|
return NewNGAlert(prometheus.DefaultRegisterer)
|
|
}
|
|
|
|
// ProvideServiceForTest is a Metrics factory used for test.
|
|
func ProvideServiceForTest() *NGAlert {
|
|
return NewNGAlert(prometheus.NewRegistry())
|
|
}
|
|
|
|
type NGAlert struct {
|
|
// Registerer is used by subcomponents which register their own metrics.
|
|
Registerer prometheus.Registerer
|
|
|
|
schedulerMetrics *Scheduler
|
|
stateMetrics *State
|
|
multiOrgAlertmanagerMetrics *MultiOrgAlertmanager
|
|
apiMetrics *API
|
|
historianMetrics *Historian
|
|
remoteAlertmanagerMetrics *RemoteAlertmanager
|
|
}
|
|
|
|
// NewNGAlert manages the metrics of all the alerting components.
|
|
func NewNGAlert(r prometheus.Registerer) *NGAlert {
|
|
return &NGAlert{
|
|
Registerer: r,
|
|
schedulerMetrics: NewSchedulerMetrics(r),
|
|
stateMetrics: NewStateMetrics(r),
|
|
multiOrgAlertmanagerMetrics: NewMultiOrgAlertmanagerMetrics(r),
|
|
apiMetrics: NewAPIMetrics(r),
|
|
historianMetrics: NewHistorianMetrics(r, Subsystem),
|
|
remoteAlertmanagerMetrics: NewRemoteAlertmanagerMetrics(r),
|
|
}
|
|
}
|
|
|
|
func (ng *NGAlert) GetSchedulerMetrics() *Scheduler {
|
|
return ng.schedulerMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetStateMetrics() *State {
|
|
return ng.stateMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetAPIMetrics() *API {
|
|
return ng.apiMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetMultiOrgAlertmanagerMetrics() *MultiOrgAlertmanager {
|
|
return ng.multiOrgAlertmanagerMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetHistorianMetrics() *Historian {
|
|
return ng.historianMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetRemoteAlertmanagerMetrics() *RemoteAlertmanager {
|
|
return ng.remoteAlertmanagerMetrics
|
|
}
|