Alerting/metrics (#33547)
* moves alerting metrics to their own pkg
* adds grafana_alerting_alerts (by state) metric
* alerts_received_{total,invalid}
* embed alertmanager alerting struct in ng metrics & remove duplicated notification metrics (already embed alertmanager notifier metrics)
* use silence metrics from alertmanager lib
* fix - manager has metrics
* updates ngalert tests
* comment lint
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
* cleaner prom registry code
* removes ngalert global metrics
* new registry use in all tests
* ngalert metrics impl service, hack testinfra code to prevent duplicate metric registrations
* nilmetrics unexported
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
)
|
||||
|
||||
@@ -16,16 +17,16 @@ type {{classname}}Service interface { {{#operation}}
|
||||
{{nickname}}(*models.ReqContext{{#bodyParams}}, apimodels.{{dataType}}{{/bodyParams}}) response.Response{{/operation}}
|
||||
}
|
||||
|
||||
func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service, metrics *Metrics) {
|
||||
func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service, m *metrics.Metrics) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister){ {{#operations}}{{#operation}}
|
||||
group.{{httpMethod}}(
|
||||
toMacaronPath("{{{path}}}"){{#bodyParams}},
|
||||
binding.Bind(apimodels.{{dataType}}{}){{/bodyParams}},
|
||||
Instrument(
|
||||
metrics.Instrument(
|
||||
http.Method{{httpMethod}},
|
||||
"{{{path}}}",
|
||||
srv.{{nickname}},
|
||||
metrics,
|
||||
m,
|
||||
),
|
||||
){{/operation}}{{/operations}}
|
||||
}, middleware.ReqSignedIn)
|
||||
|
||||
Reference in New Issue
Block a user