* Add unified_alerting.notification_history to ini files
* Parse notification history settings
* Move Loki client to a separate package
* Loki client: add params for metrics and traces
* add NotificationHistorian
* rm writeDuration
* remove RangeQuery stuff
* wip
* wip
* wip
* wip
* pass notification historian in tests
* unify loki settings
* unify loki settings
* add test
* update grafana/alerting
* make update-workspace
* add feature toggle
* fix configureNotificationHistorian
* Revert "add feature toggle"
This reverts commit de7af8f7
* add feature toggle
* more tests
* RuleUID
* fix metrics test
* met.Info.Set(0)
84 lines
2.3 KiB
Go
84 lines
2.3 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
|
|
notificationHistorianMetrics *NotificationHistorian
|
|
remoteAlertmanagerMetrics *RemoteAlertmanager
|
|
remoteWriterMetrics *RemoteWriter
|
|
}
|
|
|
|
// 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),
|
|
notificationHistorianMetrics: NewNotificationHistorianMetrics(r),
|
|
remoteAlertmanagerMetrics: NewRemoteAlertmanagerMetrics(r),
|
|
remoteWriterMetrics: NewRemoteWriterMetrics(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) GetNotificationHistorianMetrics() *NotificationHistorian {
|
|
return ng.notificationHistorianMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetRemoteAlertmanagerMetrics() *RemoteAlertmanager {
|
|
return ng.remoteAlertmanagerMetrics
|
|
}
|
|
|
|
func (ng *NGAlert) GetRemoteWriterMetrics() *RemoteWriter {
|
|
return ng.remoteWriterMetrics
|
|
}
|