Alerting: Remove internal labels from prometheus compatible API responses (#46548)

* Alerting: Remove internal labels from prometheus compatible API responses

* Appease the linter

* Fix integration tests

* Fix API documentation & linter

* move removal of internal labels to the models
This commit is contained in:
gotjosh
2022-03-16 16:04:19 +00:00
committed by GitHub
parent d5883c1b27
commit a338c78ca8
11 changed files with 290 additions and 5735 deletions
+11 -1
View File
@@ -47,7 +47,7 @@ func NewEvaluationValues(m map[string]eval.NumberValueCapture) map[string]*float
return result
}
func (a *State) resultNormal(alertRule *ngModels.AlertRule, result eval.Result) {
func (a *State) resultNormal(_ *ngModels.AlertRule, result eval.Result) {
a.Error = result.Error // should be nil since state is not error
if a.State != eval.Normal {
@@ -177,3 +177,13 @@ func (a *State) setEndsAt(alertRule *ngModels.AlertRule, result eval.Result) {
a.EndsAt = result.EvaluatedAt.Add(ends * 3)
}
func (a *State) GetLabels(opts ...ngModels.LabelOption) map[string]string {
labels := a.Labels.Copy()
for _, opt := range opts {
opt(labels)
}
return labels
}