diff --git a/pkg/services/ngalert/api/api_prometheus.go b/pkg/services/ngalert/api/api_prometheus.go index 442ab658c23..8d3533de658 100644 --- a/pkg/services/ngalert/api/api_prometheus.go +++ b/pkg/services/ngalert/api/api_prometheus.go @@ -79,7 +79,7 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Res newGroup := &apimodels.RuleGroup{ Name: groupId, // This doesn't make sense in our architecture - // so we use this field for passing to the frontend the namaspace + // so we use this field for passing to the frontend the namespace File: namespace, LastEvaluation: time.Time{}, EvaluationTime: 0, // TODO: see if we are able to pass this along with evaluation results @@ -99,7 +99,7 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Res alertingRule := apimodels.AlertingRule{ State: "inactive", Name: rule.Title, - Query: "", // TODO: get this from parsing AlertRule.Data + Query: rule.DataToString(), // TODO: don't escape <>& etc Duration: rule.For.Seconds(), Annotations: rule.Annotations, } diff --git a/pkg/services/ngalert/models/alert_rule.go b/pkg/services/ngalert/models/alert_rule.go index 6b8d4a7e579..fc1c98e3490 100644 --- a/pkg/services/ngalert/models/alert_rule.go +++ b/pkg/services/ngalert/models/alert_rule.go @@ -61,6 +61,18 @@ type AlertRule struct { Labels map[string]string } +func (alertRule *AlertRule) DataToString() string { + response := "[" + for i, part := range alertRule.Data { + response += string(part.Model) + if i < len(alertRule.Data)-1 { + response += "," + } + } + response += "]" + return response +} + // AlertRuleKey is the alert definition identifier type AlertRuleKey struct { OrgID int64