Skip to content

Commit 593e52b

Browse files
committed
Fix expected queries after upgrading Prometheus
This changes mostly the `sum by(grouping)` to `sum by (grouping)`.
1 parent 64f479f commit 593e52b

File tree

5 files changed

+146
-146
lines changed

5 files changed

+146
-146
lines changed

kubernetes/controllers/servicelevelobjective_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func Test_makePrometheusRule(t *testing.T) {
8989
Rules: []monitoringv1.Rule{
9090
{
9191
Record: "http_requests:increase4w",
92-
Expr: intstr.FromString(`sum by(status) (increase(http_requests_total{job="app"}[4w]))`),
92+
Expr: intstr.FromString(`sum by (status) (increase(http_requests_total{job="app"}[4w]))`),
9393
Labels: map[string]string{
9494
"job": "app",
9595
"slo": "http",
@@ -200,7 +200,7 @@ func Test_makeConfigMap(t *testing.T) {
200200
- interval: 2m30s
201201
name: http-increase
202202
rules:
203-
- expr: sum by(status) (increase(http_requests_total{job="app"}[4w]))
203+
- expr: sum by (status) (increase(http_requests_total{job="app"}[4w]))
204204
labels:
205205
job: app
206206
slo: http

slo/promql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (o Objective) QueryErrors(window model.Duration) string {
8585
}
8686

8787
if o.Indicator.Latency != nil && o.Indicator.Latency.Total.Name != "" {
88-
expr, err := parser.ParseExpr(`sum by(grouping) (metric{matchers="total"}) - sum by(grouping) (errorMetric{matchers="errors"})`)
88+
expr, err := parser.ParseExpr(`sum by (grouping) (metric{matchers="total"}) - sum by (grouping) (errorMetric{matchers="errors"})`)
8989
if err != nil {
9090
return ""
9191
}
@@ -394,7 +394,7 @@ func (r objectiveReplacer) replace(node parser.Node) {
394394

395395
func (o Objective) RequestRange(timerange time.Duration) string {
396396
if o.Indicator.Ratio != nil && o.Indicator.Ratio.Total.Name != "" {
397-
expr, err := parser.ParseExpr(`sum by(group) (rate(metric{}[1s])) > 0`)
397+
expr, err := parser.ParseExpr(`sum by (group) (rate(metric{}[1s])) > 0`)
398398
if err != nil {
399399
return err.Error()
400400
}
@@ -433,7 +433,7 @@ func (o Objective) RequestRange(timerange time.Duration) string {
433433

434434
func (o Objective) ErrorsRange(timerange time.Duration) string {
435435
if o.Indicator.Ratio != nil && o.Indicator.Ratio.Total.Name != "" {
436-
expr, err := parser.ParseExpr(`sum by(group) (rate(errorMetric{matchers="errors"}[1s])) / scalar(sum(rate(metric{matchers="total"}[1s]))) > 0`)
436+
expr, err := parser.ParseExpr(`sum by (group) (rate(errorMetric{matchers="errors"}[1s])) / scalar(sum(rate(metric{matchers="total"}[1s]))) > 0`)
437437
if err != nil {
438438
return err.Error()
439439
}
@@ -477,7 +477,7 @@ func (o Objective) DurationRange(timerange time.Duration, percentile float64) st
477477
}
478478

479479
if o.Indicator.Latency != nil && o.Indicator.Latency.Total.Name != "" {
480-
expr, err := parser.ParseExpr(`histogram_quantile(0.420, sum by(le) (rate(errorMetric{matchers="errors"}[1s])))`)
480+
expr, err := parser.ParseExpr(`histogram_quantile(0.420, sum by (le) (rate(errorMetric{matchers="errors"}[1s])))`)
481481
if err != nil {
482482
return err.Error()
483483
}

0 commit comments

Comments
 (0)