Skip to content

Commit

Permalink
fix(backend): escape filters
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Apr 13, 2022
1 parent 2388bd2 commit 78dd259
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Correctly set filter history.
- Correctly escape label values when quering Prometheus for alert history.

## v0.101

Expand Down
6 changes: 3 additions & 3 deletions cmd/karma/alert_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ func countAlerts(uri string, timeout time.Duration, transport http.RoundTripper,
Step: time.Hour,
}

lv := []string{}
lv := model.LabelSet{}
for k, v := range labels {
if slices.StringInSlice(names, k) {
lv = append(lv, fmt.Sprintf(`%s="%s"`, k, v))
lv[model.LabelName(k)] = model.LabelValue(v)
}
}
q := fmt.Sprintf("changes(ALERTS_FOR_STATE{%s}[1h])", strings.Join(lv, ","))
q := fmt.Sprintf("changes(ALERTS_FOR_STATE{%s}[1h])", lv)
log.Debug().
Str("uri", uri).
Interface("labels", labels).
Expand Down
2 changes: 1 addition & 1 deletion demo/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def alerts(self):
cluster="staging",
job="textfile_exporter",
region="SA",
device="Device {} (main)".format(i % 2),
device='Device {} (main) "quoted"'.format(i % 2),
regex="^device{}(.+)bar\\$".format(i),
address="10.0.0.1{}".format(i),
pod="my-pod",
Expand Down

0 comments on commit 78dd259

Please sign in to comment.