Alerting: Include annotations in prometheus Alert response. (#45970)

* Alerting: Include annotations in prometheus Alert response.

* add tests

* re-order depedencies
This commit is contained in:
gotjosh
2022-03-09 18:20:29 +00:00
committed by GitHub
parent b1e6f7126a
commit 8d4a0a0396
4 changed files with 180 additions and 2 deletions
+4 -2
View File
@@ -24,7 +24,7 @@ import (
type PrometheusSrv struct {
log log.Logger
manager *state.Manager
manager state.AlertInstanceManager
store store.RuleStore
}
@@ -43,14 +43,16 @@ func (srv PrometheusSrv) RouteGetAlertStatuses(c *models.ReqContext) response.Re
if alertState.State == eval.Alerting {
valString = alertState.LastEvaluationString
}
alertResponse.Data.Alerts = append(alertResponse.Data.Alerts, &apimodels.Alert{
Labels: map[string]string(alertState.Labels),
Annotations: map[string]string{}, //TODO: Once annotations are added to the evaluation result, set them here
Annotations: alertState.Annotations,
State: alertState.State.String(),
ActiveAt: &startsAt,
Value: valString,
})
}
return response.JSON(http.StatusOK, alertResponse)
}