Skip to content

Commit

Permalink
Don't report humanise when round is used
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Oct 27, 2022
1 parent 69aed89 commit f1a0407
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
sum(foo) without(instance) * on(app_name) group_left() bar
```
- Don't log passwords when Prometheus URI is using basic authentication.
- Fixed a false positive reports in [alerts/template](checks/alerts/template.md)
suggeting to use `humanize` on queries that already use `round()`.
## v0.30.2
Expand Down
12 changes: 12 additions & 0 deletions internal/checks/alerts_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,18 @@ func TestTemplateCheck(t *testing.T) {
expr: foo > on() sum(rate(errors[2m])
annotations:
summary: "Seeing {{ $value }} instances with errors"
`,
checker: newTemplateCheck,
prometheus: noProm,
problems: noProblems,
},
{
description: "humanize not needed on round(rate())",
content: `
- alert: Foo
expr: round(rate(errors_total[5m]), 1) > 0
annotations:
summary: "Seeing {{ $value }} instances with errors"
`,
checker: newTemplateCheck,
prometheus: noProm,
Expand Down
2 changes: 1 addition & 1 deletion internal/parser/utils/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func HasOuterRate(node *parser.PromQLNode) (calls []*promParser.Call) {
case "rate", "irate", "deriv":
calls = append(calls, n)
return calls
case "ceil", "floor":
case "ceil", "floor", "round":
return nil
}
}
Expand Down

0 comments on commit f1a0407

Please sign in to comment.