Skip to content

Commit de95def

Browse files
authored
Merge pull request #1340 from cloudflare/comments2
Use collapsible blocks for comments
2 parents 818d79f + 1b2d18e commit de95def

File tree

63 files changed

+1316
-1308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1316
-1308
lines changed

.github/pint/rules/1.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ groups:
1010

1111
- alert: Service Is Missing
1212
expr: absent({job="myjob"})
13-
for: 0m
13+
for: 0s
1414

1515
- alert: Everything Is Down
1616
expr: up:sum == 0
17+
18+
- alert: Dead Code
19+
expr: |
20+
sum(foo or vector(0)) by(name) > 0

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: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,60 @@ level=INFO msg="Checking Prometheus rules" entries=17 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`
1818
6 | expr: sum(irate(foo[3m])) WITHOUT (colo_id)
19-
| ^^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
19+
^^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
2020

2121
Warning: redundant regexp (promql/regexp)
2222
---> rules/0002.yaml:2 -> `colo_job:down:count`
2323
2 | expr: up{job=~"foo"} == 0
24-
| ^^^^^^^^^^ Unnecessary regexp match on static string `job=~"foo"`, use `job="foo"` instead.
24+
^^^^^^^^^^ Unnecessary regexp match on static string `job=~"foo"`, use `job="foo"` instead.
2525

2626
Warning: redundant regexp (promql/regexp)
2727
---> rules/0002.yaml:5 -> `colo_job:down:count`
2828
5 | expr: up{job!~"foo"} == 0
29-
| ^^^^^^^^^^ Unnecessary regexp match on static string `job!~"foo"`, use `job!="foo"` instead.
29+
^^^^^^^^^^ Unnecessary regexp match on static string `job!~"foo"`, use `job!="foo"` instead.
3030

3131
Warning: label must be removed in aggregations (promql/aggregate)
3232
---> rules/0003.yaml:11 -> `colo_job:up:count`
3333
11 | expr: sum(foo) without(job)
34-
| ^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
34+
^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
3535

3636
Warning: required label is being removed via aggregation (promql/aggregate)
3737
---> rules/0003.yaml:11 -> `colo_job:up:count`
3838
11 | expr: sum(foo) without(job)
39-
| ^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
40-
| `job` label is required and should be preserved when aggregating all rules.
39+
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
40+
`job` label is required and should be preserved when aggregating all rules.
4141

4242
Fatal: PromQL syntax error (promql/syntax)
4343
---> rules/0003.yaml:14 -> `invalid`
4444
14 | expr: sum(foo) by ())
45-
| ^ unexpected right parenthesis ')'
45+
^ unexpected right parenthesis ')'
4646

4747
Warning: required label is being removed via aggregation (promql/aggregate)
4848
---> rules/0003.yaml:23-25 -> `colo:multiline`
4949
23 | sum(
5050
24 | multiline
5151
25 | ) without(job, instance)
52-
| ^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
53-
| `job` label is required and should be preserved when aggregating all rules.
52+
^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
53+
`job` label is required and should be preserved when aggregating all rules.
5454

5555
Warning: label must be removed in aggregations (promql/aggregate)
5656
---> rules/0003.yaml:29-31 -> `colo:multiline:sum`
5757
29 | sum(sum) without(job)
58-
| ^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
58+
^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
5959
30 | +
6060
31 | sum(sum) without(job)
6161

6262
Warning: required label is being removed via aggregation (promql/aggregate)
6363
---> rules/0003.yaml:29-31 -> `colo:multiline:sum`
6464
29 | sum(sum) without(job)
65-
| ^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
66-
| `job` label is required and should be preserved when aggregating all rules.
65+
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
66+
`job` label is required and should be preserved when aggregating all rules.
6767
30 | +
6868
31 | sum(sum) without(job)
6969

@@ -72,27 +72,27 @@ Warning: required label is being removed via aggregation (promql/aggregate)
7272
35 | sum(
7373
36 | multiline2
7474
37 | ) without(job, instance)
75-
| ^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
76-
| `job` label is required and should be preserved when aggregating all rules.
75+
^^^^^^^ Query is using aggregation with `without(job, instance)`, all labels included inside `without(...)` will be removed from the results.
76+
`job` label is required and should be preserved when aggregating all rules.
7777

7878
Warning: label must be removed in aggregations (promql/aggregate)
7979
---> rules/0003.yaml:40 -> `colo_job:up:byinstance`
8080
40 | expr: sum(byinstance) by(instance)
81-
| ^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
81+
^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.
8282

8383
Warning: required label is being removed via aggregation (promql/aggregate)
8484
---> rules/0003.yaml:40 -> `colo_job:up:byinstance`
8585
40 | expr: sum(byinstance) by(instance)
86-
| ^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
87-
| `job` label is required and should be preserved when aggregating all rules.
86+
^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
87+
`job` label is required and should be preserved when aggregating all rules.
8888

8989
Information: use humanize filters for the results (alerts/template)
9090
---> rules/0003.yaml:58-61 -> `Error Rate`
9191
58 | expr: sum(rate(errors[5m])) > 0.5
92-
| ^^^^^^^^^^^^^^^^ `rate()` will produce results that are hard to read for humans.
92+
^^^^^^^^^^^^^^^^ `rate()` will produce results that are hard to read for humans.
9393
| [...]
9494
61 | summary: 'error rate: {{ $value }}'
95-
| ^^^^^^^^^^^^^^^^^^^^^^^^ Use one of humanize template functions to make the result more readable.
95+
^^^^^^^^^^^^^^^^^^^^^^^^ Use one of humanize template functions to make the result more readable.
9696

9797
level=INFO msg="Problems found" Fatal=1 Warning=12 Information=1
9898
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"

cmd/pint/tests/0004_fail_invalid_yaml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Fatal: did not find expected key (yaml/parse)
1515
Fatal: PromQL syntax error (promql/syntax)
1616
---> rules/ok.yml:5 -> `sum:missing`
1717
5 | expr: sum(foo[5m)
18-
| ^ unclosed left bracket
18+
^ unclosed left bracket
1919

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

cmd/pint/tests/0007_alerts.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,67 +9,67 @@ level=INFO msg="Checking Prometheus rules" entries=6 workers=10 online=true
99
Warning: required label not set (rule/label)
1010
---> rules/0001.yml:1-2 -> `Always`
1111
2 | expr: up
12-
| ^^ `severity` label is required.
12+
^^ `severity` label is required.
1313

1414
Bug: required annotation not set (alerts/annotation)
1515
---> rules/0001.yml:1-2 -> `Always`
1616
2 | expr: up
17-
| ^^ `url` annotation is required.
17+
^^ `url` annotation is required.
1818

1919
Warning: always firing alert (alerts/comparison)
2020
---> rules/0001.yml:2 -> `Always`
2121
2 | expr: up
22-
| ^^ Alert query doesn't have any condition, it will always fire if the metric exists.
22+
^^ Alert query doesn't have any condition, it will always fire if the metric exists.
2323

2424
Warning: required label not set (rule/label)
2525
---> rules/0001.yml:9-10 -> `ServiceIsDown`
2626
10 | expr: up == 0
27-
| ^^^ `severity` label is required.
27+
^^^ `severity` label is required.
2828

2929
Bug: required annotation not set (alerts/annotation)
3030
---> rules/0001.yml:9-10 -> `ServiceIsDown`
3131
10 | expr: up == 0
32-
| ^^^ `url` annotation is required.
32+
^^^ `url` annotation is required.
3333

3434
Warning: invalid label value (rule/label)
3535
---> rules/0001.yml:14 -> `ServiceIsDown`
3636
14 | severity: bad
37-
| ^^^ `severity` label value must match `^critical|warning|info$`.
37+
^^^ `severity` label value must match `^critical|warning|info$`.
3838

3939
Bug: invalid annotation value (alerts/annotation)
4040
---> rules/0001.yml:16 -> `ServiceIsDown`
4141
16 | url: bad
42-
| ^^^ `url` annotation value must match `^https://wiki.example.com/page/(.+).html$`.
42+
^^^ `url` annotation value must match `^https://wiki.example.com/page/(.+).html$`.
4343

4444
Fatal: template syntax error (alerts/template)
4545
---> rules/0002.yml:5 -> `Foo Is Down`
4646
5 | summary: 'Instance {{ $label.instance }} down'
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$label"`.
47+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$label"`.
4848

4949
Fatal: template syntax error (alerts/template)
5050
---> rules/0002.yml:6 -> `Foo Is Down`
5151
6 | func: '{{ $valuexx | xxx }}'
52-
| ^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$valuexx"`.
52+
^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$valuexx"`.
5353

5454
Fatal: template syntax error (alerts/template)
5555
---> rules/0002.yml:9 -> `Foo Is Down`
5656
9 | summary: 'Instance {{ $label.instance }} down'
57-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$label"`.
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `undefined variable "$label"`.
5858

5959
Fatal: template syntax error (alerts/template)
6060
---> rules/0002.yml:10 -> `Foo Is Down`
6161
10 | func: '{{ $value | xxx }}'
62-
| ^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `function "xxx" not defined`.
62+
^^^^^^^^^^^^^^^^^^ Template failed to parse with this error: `function "xxx" not defined`.
6363

6464
Bug: value used in labels (alerts/template)
6565
---> rules/0002.yml:11 -> `Foo Is Down`
6666
11 | bar: 'Some {{$value}} value'
67-
| ^^^^^^^^^^^^^^^^^^^^^ Using `$value` in labels will generate a new alert on every value change, move it to annotations.
67+
^^^^^^^^^^^^^^^^^^^^^ Using `$value` in labels will generate a new alert on every value change, move it to annotations.
6868

6969
Bug: value used in labels (alerts/template)
7070
---> rules/0002.yml:12 -> `Foo Is Down`
7171
12 | val: '{{ .Value|humanizeDuration }}'
72-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Using `.Value` in labels will generate a new alert on every value change, move it to annotations.
72+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Using `.Value` in labels will generate a new alert on every value change, move it to annotations.
7373

7474
level=INFO msg="Problems found" Fatal=4 Bug=5 Warning=4
7575
level=ERROR msg="Execution completed with error(s)" err="found 2 problem(s) with severity Bug or higher"

cmd/pint/tests/0008_recording_rule_prometheus.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=1 workers=10 online=true
99
Warning: required label is being removed via aggregation (promql/aggregate)
1010
---> rules/0001.yml:5 -> `colo:http_inprogress_requests:sum`
1111
5 | expr: sum by (instance) (http_inprogress_requests)
12-
| ^^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
13-
| `job` label is required and should be preserved when aggregating all rules.
12+
^^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
13+
`job` label is required and should be preserved when aggregating all rules.
1414

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/0009_alerting_rule_prometheus.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true
99
Bug: required annotation not set (alerts/annotation)
1010
---> rules/0001.yml:6-13 -> `InstanceDown`
1111
13 | description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."
12-
| ^^^ `link` annotation is required.
12+
^^^ `link` annotation is required.
1313

1414
Bug: required annotation not set (alerts/annotation)
1515
---> rules/0001.yml:16-21 -> `APIHighRequestLatency`
1616
21 | description: "{{ $labels.instance }} has a median request latency above 1s (current value: {{ $value }}s)"
17-
| ^^^ `link` annotation is required.
17+
^^^ `link` annotation is required.
1818

1919
Warning: required label is being removed via aggregation (promql/aggregate)
2020
---> rules/0001.yml:17 -> `APIHighRequestLatency`
2121
17 | expr: sum by (instance) (http_inprogress_requests) > 0
22-
| ^^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
23-
| `job` label is required and should be preserved when aggregating all rules.
22+
^^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
23+
`job` label is required and should be preserved when aggregating all rules.
2424

2525
level=INFO msg="Problems found" Bug=2 Warning=1
2626
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ level=INFO msg="Checking Prometheus rules" entries=10 workers=10 online=true
99
Fatal: PromQL syntax error (promql/syntax)
1010
---> rules/1.yaml:5 -> `active`
1111
5 | expr: sum(errors_total) by )
12-
| ^ unexpected right parenthesis ')'
12+
^ unexpected right parenthesis ')'
1313

1414
Warning: required label is being removed via aggregation (promql/aggregate)
1515
---> rules/1.yaml:16 -> `active`
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
Fatal: PromQL syntax error (promql/syntax)
2121
---> rules/1.yaml:22 -> `active`
2222
22 | expr: sum(errors_total) by )
23-
| ^ unexpected right parenthesis ')'
23+
^ unexpected right parenthesis ')'
2424

2525
Warning: always firing alert (alerts/comparison)
2626
---> rules/1.yaml:33 -> `active`
2727
33 | expr: sum(errors_total) without(job)
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Alert query doesn't have any condition, it will always fire if the metric exists.
28+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Alert query doesn't have any condition, it will always fire if the metric exists.
2929

3030
Warning: required label is being removed via aggregation (promql/aggregate)
3131
---> rules/1.yaml:33 -> `active`
3232
33 | expr: sum(errors_total) without(job)
33-
| ^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
34-
| `job` label is required and should be preserved when aggregating all rules.
33+
^^^^^^^ Query is using aggregation with `without(job)`, all labels included inside `without(...)` will be removed from the results.
34+
`job` label is required and should be preserved when aggregating all rules.
3535

3636
level=INFO msg="Problems found" Fatal=2 Warning=3
3737
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"

cmd/pint/tests/0012_issue_20.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true
99
Warning: required annotation not set (alerts/annotation)
1010
---> rules/1.yaml:4-11 -> `HaproxyServerHealthcheckFailure`
1111
11 | description: "Some server healthcheck are failing on {{ $labels.server }}\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
12-
| ^^^ `runbook_url` annotation is required.
12+
^^^ `runbook_url` annotation is required.
1313

1414
level=INFO msg="Problems found" Warning=1
1515
-- rules/1.yaml --

0 commit comments

Comments
 (0)