mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Handle NoData and Error evaluation results (#33194)
* set processing time * merge labels and set on response * use state cache for adding alerts to rules * minor cleanup * add support for NoData and Error results * rename test * bring in changes from other PRs tha have been merged * pr feedback * add integration test * close state tracker cleanup on context.Done * fixup test * not those annotations
This commit is contained in:
@@ -51,7 +51,9 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Res
|
||||
DiscoveryBase: apimodels.DiscoveryBase{
|
||||
Status: "success",
|
||||
},
|
||||
Data: apimodels.RuleDiscovery{},
|
||||
Data: apimodels.RuleDiscovery{
|
||||
RuleGroups: []*apimodels.RuleGroup{},
|
||||
},
|
||||
}
|
||||
|
||||
ruleGroupQuery := ngmodels.ListOrgRuleGroupsQuery{
|
||||
@@ -99,7 +101,7 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Res
|
||||
newRule := apimodels.Rule{
|
||||
Name: rule.Title,
|
||||
Labels: rule.Labels,
|
||||
Health: "ok", // TODO: update this in the future when error and noData states are being evaluated and set
|
||||
Health: "ok",
|
||||
Type: apiv1.RuleTypeAlerting,
|
||||
LastEvaluation: time.Time{},
|
||||
}
|
||||
@@ -131,9 +133,9 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Res
|
||||
case eval.Alerting:
|
||||
alertingRule.State = "firing"
|
||||
case eval.Error:
|
||||
// handle Error case based on configuration in alertRule
|
||||
newRule.Health = "error"
|
||||
case eval.NoData:
|
||||
// handle NoData case based on configuration in alertRule
|
||||
newRule.Health = "nodata"
|
||||
}
|
||||
alertingRule.Alerts = append(alertingRule.Alerts, alert)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user