Alerting: Refactor & fix unified alerting metrics structure (#39151)
* Alerting: Refactor & fix unified alerting metrics structure Fixes and refactors the metrics structure we have for the ngalert service. Now, each component has its own metric struct that includes the JUST the metrics it uses. Additionally, I have fixed the configuration metrics and added new metrics to determine if we have discovered and started all the necessary configurations of an instance. This allows us to alert on `grafana_alerting_discovered_configurations - grafana_alerting_active_configurations != 0` to know whether an alertmanager instance did not start successfully.
This commit is contained in:
@@ -66,7 +66,7 @@ type API struct {
|
||||
}
|
||||
|
||||
// RegisterAPIEndpoints registers API handlers
|
||||
func (api *API) RegisterAPIEndpoints(m *metrics.Metrics) {
|
||||
func (api *API) RegisterAPIEndpoints(m *metrics.API) {
|
||||
logger := log.New("ngalert.api")
|
||||
proxy := &AlertingProxy{
|
||||
DataProxy: api.DataProxy,
|
||||
|
||||
@@ -34,7 +34,7 @@ type AlertmanagerApiService interface {
|
||||
RoutePostTestReceivers(*models.ReqContext, apimodels.TestReceiversConfigParams) response.Response
|
||||
}
|
||||
|
||||
func (api *API) RegisterAlertmanagerApiEndpoints(srv AlertmanagerApiService, m *metrics.Metrics) {
|
||||
func (api *API) RegisterAlertmanagerApiEndpoints(srv AlertmanagerApiService, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
||||
group.Post(
|
||||
toMacaronPath("/api/alertmanager/{Recipient}/api/v2/silences"),
|
||||
|
||||
@@ -26,7 +26,7 @@ type ConfigurationApiService interface {
|
||||
RoutePostNGalertConfig(*models.ReqContext, apimodels.PostableNGalertConfig) response.Response
|
||||
}
|
||||
|
||||
func (api *API) RegisterConfigurationApiEndpoints(srv ConfigurationApiService, m *metrics.Metrics) {
|
||||
func (api *API) RegisterConfigurationApiEndpoints(srv ConfigurationApiService, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
||||
group.Delete(
|
||||
toMacaronPath("/api/v1/ngalert/admin_config"),
|
||||
|
||||
@@ -21,7 +21,7 @@ type PrometheusApiService interface {
|
||||
RouteGetRuleStatuses(*models.ReqContext) response.Response
|
||||
}
|
||||
|
||||
func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiService, m *metrics.Metrics) {
|
||||
func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiService, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
||||
group.Get(
|
||||
toMacaronPath("/api/prometheus/{Recipient}/api/v1/alerts"),
|
||||
|
||||
@@ -28,7 +28,7 @@ type RulerApiService interface {
|
||||
RoutePostNameRulesConfig(*models.ReqContext, apimodels.PostableRuleGroupConfig) response.Response
|
||||
}
|
||||
|
||||
func (api *API) RegisterRulerApiEndpoints(srv RulerApiService, m *metrics.Metrics) {
|
||||
func (api *API) RegisterRulerApiEndpoints(srv RulerApiService, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
||||
group.Delete(
|
||||
toMacaronPath("/api/ruler/{Recipient}/api/v1/rules/{Namespace}"),
|
||||
|
||||
@@ -24,7 +24,7 @@ type TestingApiService interface {
|
||||
RouteTestRuleConfig(*models.ReqContext, apimodels.TestRulePayload) response.Response
|
||||
}
|
||||
|
||||
func (api *API) RegisterTestingApiEndpoints(srv TestingApiService, m *metrics.Metrics) {
|
||||
func (api *API) RegisterTestingApiEndpoints(srv TestingApiService, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
||||
group.Post(
|
||||
toMacaronPath("/api/v1/eval"),
|
||||
|
||||
@@ -17,7 +17,7 @@ type {{classname}}Service interface { {{#operation}}
|
||||
{{nickname}}(*models.ReqContext{{#bodyParams}}, apimodels.{{dataType}}{{/bodyParams}}) response.Response{{/operation}}
|
||||
}
|
||||
|
||||
func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service, m *metrics.Metrics) {
|
||||
func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service, m *metrics.API) {
|
||||
api.RouteRegister.Group("", func(group routing.RouteRegister){ {{#operations}}{{#operation}}
|
||||
group.{{httpMethod}}(
|
||||
toMacaronPath("{{{path}}}"){{#bodyParams}},
|
||||
|
||||
Reference in New Issue
Block a user