Skip to content

Commit

Permalink
fix(slos): BoolGauge promql expr should not be multiplied by 100
Browse files Browse the repository at this point in the history
  • Loading branch information
alexberry committed Sep 3, 2024
1 parent 4648b30 commit dccf1ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion slo/promql.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ func (o Objective) ErrorsRange(timerange time.Duration) string {

return expr.String()
case BoolGauge:
expr, err := parser.ParseExpr(`100 * sum by (group) ((count_over_time(metric{matchers="total"}[1s]) - sum_over_time(metric{matchers="total"}[1s]))) / sum by(group) (count_over_time(metric{matchers="total"}[1s]))`)
expr, err := parser.ParseExpr(`sum by (group) ((count_over_time(metric{matchers="total"}[1s]) - sum_over_time(metric{matchers="total"}[1s]))) / sum by(group) (count_over_time(metric{matchers="total"}[1s]))`)
if err != nil {
return err.Error()
}
Expand Down
4 changes: 2 additions & 2 deletions slo/promql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,12 @@ func TestObjective_ErrorsRange(t *testing.T) {
}, {
name: "up-targets",
objective: objectiveUpTargets(),
expected: `100 * sum((count_over_time(up[2h]) - sum_over_time(up[2h]))) / sum(count_over_time(up[2h]))`,
expected: `sum((count_over_time(up[2h]) - sum_over_time(up[2h]))) / sum(count_over_time(up[2h]))`,
timerange: 2 * time.Hour,
}, {
name: "up-targets-grouping-index",
objective: objectiveUpTargetsGroupingRegex(),
expected: `100 * sum((count_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]) - sum_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]))) / sum(count_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]))`,
expected: `sum((count_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]) - sum_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]))) / sum(count_over_time(up{instance!~"(127.0.0.1|localhost).*"}[2h]))`,
timerange: 2 * time.Hour,
}}

Expand Down

0 comments on commit dccf1ac

Please sign in to comment.