Instrument/ruler api (#33290)

* ruler api histogram instrumentation

* register ruler metrics
This commit is contained in:
Owen Diehl
2021-04-27 08:25:32 -04:00
committed by GitHub
parent be1affe0a4
commit 86c8eed386
3 changed files with 56 additions and 14 deletions
+10
View File
@@ -4,6 +4,7 @@ import (
"time"
"github.com/grafana/grafana/pkg/services/ngalert/state"
"github.com/prometheus/client_golang/prometheus"
"github.com/go-macaron/binding"
@@ -59,6 +60,14 @@ func (api *API) RegisterAPIEndpoints() {
proxy := &AlertingProxy{
DataProxy: api.DataProxy,
}
var reg prometheus.Registerer
// hack, this just assumes that if this histogram is enabled, we should enable others
// TODO(owen-d): expose this as a config option (alerting-instrumentation or similar)
if api.Cfg.IsHTTPRequestHistogramEnabled() {
reg = prometheus.DefaultRegisterer
}
// Register endpoints for proxing to Alertmanager-compatible backends.
api.RegisterAlertmanagerApiEndpoints(NewForkedAM(
api.DatasourceCache,
@@ -76,6 +85,7 @@ func (api *API) RegisterAPIEndpoints() {
api.DatasourceCache,
NewLotexRuler(proxy, logger),
RulerSrv{store: api.RuleStore, log: logger},
reg,
))
api.RegisterTestingApiEndpoints(TestingApiSrv{
AlertingProxy: proxy,