Skip to content

Commit 6f43db4

Browse files
authored
Merge pull request #1605 from cloudflare/promql/impssible
Check for dead labels in joins
2 parents 5a89c5b + 95ccf44 commit 6f43db4

29 files changed

+5967
-1101
lines changed

cmd/pint/tests/0001_match_path.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true
99
Bug: required label is being removed via aggregation (promql/aggregate)
1010
---> rules/0002.yml:2 -> `colo:test2`
1111
2 | expr: sum(foo) without(job)
12-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
13-
`job` label is required and should be preserved when aggregating all rules.
12+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
13+
`job` label is required and should be preserved when aggregating all rules.
1414

1515
level=INFO msg="Problems found" Bug=1
1616
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"

cmd/pint/tests/0003_lint_workdir.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ level=INFO msg="Checking Prometheus rules" entries=19 workers=10 online=true
1010
Warning: required label is being removed via aggregation (promql/aggregate)
1111
---> rules/0001.yml:2 -> `colo_job:fl_cf_html_bytes_in:rate10m`
1212
2 | expr: sum(rate(fl_cf_html_bytes_in[10m])) WITHOUT (colo_id, instance, node_type, region, node_status, job, colo_name)
13-
^^^^^^^^ Query is using aggregation with `without(colo_id, instance, node_type, region, node_status, job, colo_name)`, all labels included inside `without(...)` will be removed from the results.
14-
`job` label is required and should be preserved when aggregating all rules.
13+
^^^ Query is using aggregation with `without(colo_id, instance, node_type, region, node_status, job, colo_name)`, all labels included inside `without(...)` will be removed from the results.
14+
`job` label is required and should be preserved when aggregating all rules.
1515

1616
Warning: label must be removed in aggregations (promql/aggregate)
1717
---> rules/0001.yml:6 -> `colo_job:foo:irate3m` [+3 duplicates]
@@ -31,8 +31,8 @@ Warning: redundant regexp (promql/regexp)
3131
Warning: required label is being removed via aggregation (promql/aggregate)
3232
---> rules/0003.yaml:11 -> `colo_job:up:count` [+1 duplicates]
3333
11 | expr: sum(foo) without(job)
34-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
35-
`job` label is required and should be preserved when aggregating all rules.
34+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
35+
`job` label is required and should be preserved when aggregating all rules.
3636

3737
Fatal: PromQL syntax error (promql/syntax)
3838
---> rules/0003.yaml:14 -> `invalid`
@@ -44,8 +44,8 @@ Warning: required label is being removed via aggregation (promql/aggregate)
4444
23 | sum(
4545
24 | multiline
4646
25 | ) without(job, instance)
47-
^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
48-
`job` label is required and should be preserved when aggregating all rules.
47+
^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
48+
`job` label is required and should be preserved when aggregating all rules.
4949

5050
Warning: required label is being removed via aggregation (promql/aggregate)
5151
---> rules/0003.yaml:40 -> `colo_job:up:byinstance`

cmd/pint/tests/0008_recording_rule_prometheus.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Warning: required label is being removed via aggregation (promql/aggregate)
1515
Bug: label must be removed in aggregations (promql/aggregate)
1616
---> rules/0001.yml:5 -> `colo:http_inprogress_requests:sum`
1717
5 | expr: sum by (instance) (http_inprogress_requests)
18-
^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
18+
^^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
1919

2020
level=INFO msg="Problems found" Bug=1 Warning=1
2121
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"

cmd/pint/tests/0011_ignore_rules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Fatal: PromQL syntax error (promql/syntax)
1414
Warning: required label is being removed via aggregation (promql/aggregate)
1515
---> rules/1.yaml:16 -> `active` [+1 duplicates]
1616
16 | expr: sum(errors_total) without(job)
17-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
18-
`job` label is required and should be preserved when aggregating all rules.
17+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
18+
`job` label is required and should be preserved when aggregating all rules.
1919

2020
Warning: always firing alert (alerts/comparison)
2121
---> rules/1.yaml:33 -> `active`

cmd/pint/tests/0018_match_alerting.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Warning: always firing alert (alerts/comparison)
2222
Warning: required label is being removed via aggregation (promql/aggregate)
2323
---> rules/0001.yml:5 -> `colo:alerting`
2424
5 | expr: sum(bar) without(job)
25-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
26-
`job` label is required and should be preserved when aggregating all rules.
25+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
26+
`job` label is required and should be preserved when aggregating all rules.
2727

2828
level=INFO msg="Problems found" Warning=2
2929
-- rules/0001.yml --

cmd/pint/tests/0019_match_recording.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo
1717
Warning: required label is being removed via aggregation (promql/aggregate)
1818
---> rules/0001.yml:2 -> `colo:recording`
1919
2 | expr: sum(foo) without(job)
20-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21-
`job` label is required and should be preserved when aggregating all rules.
20+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21+
`job` label is required and should be preserved when aggregating all rules.
2222

2323
level=INFO msg="Problems found" Warning=1
2424
-- rules/0001.yml --

cmd/pint/tests/0020_ignore_kind.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo
1717
Warning: required label is being removed via aggregation (promql/aggregate)
1818
---> rules/0001.yml:5 -> `colo:recording`
1919
5 | expr: sum(foo) without(job)
20-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21-
`job` label is required and should be preserved when aggregating all rules.
20+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21+
`job` label is required and should be preserved when aggregating all rules.
2222

2323
Warning: always firing alert (alerts/comparison)
2424
---> rules/0001.yml:8 -> `colo:alerting`

cmd/pint/tests/0022_ignore_multi.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true
99
Warning: label must be removed in aggregations (promql/aggregate)
1010
---> rules/1.yaml:2 -> `disabled`
1111
2 | expr: sum(errors_total) by(keep,dropped)
12-
^^ `dropped` label should be removed when aggregating all rules.
12+
^^^^^^^ `dropped` label should be removed when aggregating all rules.
1313

1414
Warning: required label is being removed via aggregation (promql/aggregate)
1515
---> rules/1.yaml:5 -> `B`
1616
5 | expr: sum(errors_total) without(keep,dropped)
17-
^^^^^^^ Query is using aggregation with `without(keep, dropped)`, all labels included inside `without(...)` will be removed from the results.
18-
`keep` label is required and should be preserved when aggregating all rules.
17+
^^^^ Query is using aggregation with `without(keep, dropped)`, all labels included inside `without(...)` will be removed from the results.
18+
`keep` label is required and should be preserved when aggregating all rules.
1919

2020
level=INFO msg="Problems found" Warning=2
2121
-- rules/1.yaml --

cmd/pint/tests/0024_color_output.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ cmp stderr stderr.txt
1010
Warning: required label is being removed via aggregation (promql/aggregate)
1111
 ---> rules/0001.yml:2 -> `colo_job:fl_cf_html_bytes_in:rate10m`
1212
2 |  expr: sum(rate(fl_cf_html_bytes_in[10m])) WITHOUT (colo_id, instance, node_type, region, node_status, job, colo_name)
13-
 ^^^^^^^^ Query is using aggregation with `without(colo_id, instance, node_type, region, node_status, job, colo_name)`, all labels included inside `without(...)` will be removed from the results.
14-
  `job` label is required and should be preserved when aggregating all rules.
13+
 ^^^ Query is using aggregation with `without(colo_id, instance, node_type, region, node_status, job, colo_name)`, all labels included inside `without(...)` will be removed from the results.
14+
  `job` label is required and should be preserved when aggregating all rules.
1515

1616
Warning: label must be removed in aggregations (promql/aggregate)
1717
 ---> rules/0001.yml:6 -> `colo_job:foo:irate3m` [+3 duplicates]
@@ -21,8 +21,8 @@ cmp stderr stderr.txt
2121
Warning: required label is being removed via aggregation (promql/aggregate)
2222
 ---> rules/0003.yaml:11 -> `colo_job:up:count` [+1 duplicates]
2323
11 |  expr: sum(foo) without(job)
24-
 ^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
25-
  `job` label is required and should be preserved when aggregating all rules.
24+
 ^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
25+
  `job` label is required and should be preserved when aggregating all rules.
2626

2727
Fatal: PromQL syntax error (promql/syntax)
2828
 ---> rules/0003.yaml:14 -> `invalid`
@@ -34,8 +34,8 @@ cmp stderr stderr.txt
3434
23 |  sum(
3535
24 |  multiline
3636
25 |  ) without(job, instance)
37-
 ^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
38-
  `job` label is required and should be preserved when aggregating all rules.
37+
 ^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
38+
  `job` label is required and should be preserved when aggregating all rules.
3939

4040
Warning: required label is being removed via aggregation (promql/aggregate)
4141
 ---> rules/0003.yaml:40 -> `colo_job:up:byinstance`

cmd/pint/tests/0052_match_multiple.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo
1717
Warning: required label is being removed via aggregation (promql/aggregate)
1818
---> rules/0001.yml:5 -> `colo:recording` [+1 duplicates]
1919
5 | expr: sum(foo) without(job)
20-
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21-
`job` label is required and should be preserved when aggregating all rules.
20+
^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
21+
`job` label is required and should be preserved when aggregating all rules.
2222

2323
level=INFO msg="Some problems are duplicated between rules and all the duplicates were hidden, pass `--show-duplicates` to see them" total=2 duplicates=1 shown=1
2424
level=INFO msg="Problems found" Warning=2

0 commit comments

Comments
 (0)