diff --git a/cmd/pint/tests/0037_disable_checks.txt b/cmd/pint/tests/0037_disable_checks.txt index 220c8cc4..40f90b86 100644 --- a/cmd/pint/tests/0037_disable_checks.txt +++ b/cmd/pint/tests/0037_disable_checks.txt @@ -12,8 +12,8 @@ level=DEBUG msg="Starting query workers" name=prom uri=http://127.0.0.1 workers= level=DEBUG msg="Generated all Prometheus servers" count=1 level=DEBUG msg="Found alerting rule" path=rules/0001.yml alert=default-for lines=1-3 level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/template","promql/fragile","promql/regexp","promql/vector_matching(prom)","rule/duplicate(prom)","labels/conflict(prom)"] path=rules/0001.yml rule=default-for -level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum-job lines=5-6 -level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/template","promql/fragile","promql/regexp","promql/vector_matching(prom)","rule/duplicate(prom)","labels/conflict(prom)","promql/aggregate(job:true)"] path=rules/0001.yml rule=sum-job +level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum:job lines=5-6 +level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/template","promql/fragile","promql/regexp","promql/vector_matching(prom)","rule/duplicate(prom)","labels/conflict(prom)","promql/aggregate(job:true)"] path=rules/0001.yml rule=sum:job level=DEBUG msg="Found alerting rule" path=rules/0001.yml alert=no-comparison lines=8-9 level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/template","promql/fragile","promql/regexp","promql/vector_matching(prom)","rule/duplicate(prom)","labels/conflict(prom)"] path=rules/0001.yml rule=no-comparison rules/0001.yml:6 Warning: `job` label is required and should be preserved when aggregating `^.+$` rules, use `by(job, ...)`. (promql/aggregate) @@ -26,7 +26,7 @@ level=DEBUG msg="Stopping query workers" name=prom uri=http://127.0.0.1 expr: foo > 1 for: 0m -- record: sum-job +- record: sum:job expr: sum(foo) - alert: no-comparison diff --git a/cmd/pint/tests/0038_disable_checks_regex.txt b/cmd/pint/tests/0038_disable_checks_regex.txt index e393e872..faa8cb02 100644 --- a/cmd/pint/tests/0038_disable_checks_regex.txt +++ b/cmd/pint/tests/0038_disable_checks_regex.txt @@ -14,7 +14,7 @@ level=INFO msg="Problems found" Warning=1 expr: foo > 1 for: 0m -- record: sum-job +- record: sum:job expr: sum(foo) - alert: no-comparison diff --git a/cmd/pint/tests/0077_strict_error_owner.txt b/cmd/pint/tests/0077_strict_error_owner.txt index 31dac220..8544d3d9 100644 --- a/cmd/pint/tests/0077_strict_error_owner.txt +++ b/cmd/pint/tests/0077_strict_error_owner.txt @@ -4,19 +4,22 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] -rules/strict.yml:4 Fatal: YAML parser returned an error when reading this file: `"foo bar": invalid field 'annotations' in recording rule`. (yaml/parse) - 4 | - record: foo bar +rules/strict.yml:4-7 Bug: `rule/owner` comments are required in all files, please add a `# pint file/owner $owner` somewhere in this file and/or `# pint rule/owner $owner` on top of each rule. (rule/owner) + 4 | - alert: foo bar + 5 | expr: 0 + 6 | annotations: + 7 | foo: bar -rules/strict.yml:4 Fatal: YAML parser returned an error when reading this file: `"foo bar": invalid recording rule name: foo bar`. (yaml/parse) - 4 | - record: foo bar +rules/strict.yml:5 Warning: Alert query doesn't have any condition, it will always fire if the metric exists. (alerts/comparison) + 5 | expr: 0 -level=INFO msg="Problems found" Fatal=2 +level=INFO msg="Problems found" Bug=1 Warning=1 level=ERROR msg="Fatal error" err="found 1 problem(s) with severity Bug or higher" -- rules/strict.yml -- groups: - name: foo rules: - - record: foo bar + - alert: foo bar expr: 0 annotations: foo: bar diff --git a/cmd/pint/tests/0111_snooze.txt b/cmd/pint/tests/0111_snooze.txt index 6a5d6e2f..067ffb64 100644 --- a/cmd/pint/tests/0111_snooze.txt +++ b/cmd/pint/tests/0111_snooze.txt @@ -8,12 +8,12 @@ level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 level=DEBUG msg="Generated all Prometheus servers" count=0 -level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum-job lines=2-3 +level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum:job lines=2-3 level=DEBUG msg="Check snoozed by comment" check=promql/aggregate(job:true) match=promql/aggregate until="2099-11-28T10:24:18Z" -level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/0001.yml rule=sum-job +level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/0001.yml rule=sum:job -- rules/0001.yml -- # pint snooze 2099-11-28T10:24:18Z promql/aggregate -- record: sum-job +- record: sum:job expr: sum(foo) -- .pint.hcl -- diff --git a/cmd/pint/tests/0112_expired_snooze.txt b/cmd/pint/tests/0112_expired_snooze.txt index c02a7f86..ee770c9b 100644 --- a/cmd/pint/tests/0112_expired_snooze.txt +++ b/cmd/pint/tests/0112_expired_snooze.txt @@ -8,8 +8,8 @@ level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 level=DEBUG msg="Generated all Prometheus servers" count=0 -level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum-job lines=2-3 -level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp","promql/aggregate(job:true)"] path=rules/0001.yml rule=sum-job +level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum:job lines=2-3 +level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp","promql/aggregate(job:true)"] path=rules/0001.yml rule=sum:job rules/0001.yml:3 Bug: `job` label is required and should be preserved when aggregating `^.+$` rules, use `by(job, ...)`. (promql/aggregate) 3 | expr: sum(foo) @@ -17,7 +17,7 @@ level=INFO msg="Problems found" Bug=1 level=ERROR msg="Fatal error" err="found 1 problem(s) with severity Bug or higher" -- rules/0001.yml -- # pint snooze 2000-11-28T10:24:18Z promql/aggregate -- record: sum-job +- record: sum:job expr: sum(foo) -- .pint.hcl -- diff --git a/cmd/pint/tests/0116_file_snooze.txt b/cmd/pint/tests/0116_file_snooze.txt index bada200b..ac70bfbf 100644 --- a/cmd/pint/tests/0116_file_snooze.txt +++ b/cmd/pint/tests/0116_file_snooze.txt @@ -10,15 +10,15 @@ level=DEBUG msg="Check snoozed by comment" check=alerts/for match=alerts/for unt level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 level=DEBUG msg="Generated all Prometheus servers" count=0 -level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum-job lines=4-5 -level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/0001.yml rule=sum-job +level=DEBUG msg="Found recording rule" path=rules/0001.yml record=sum:job lines=4-5 +level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/0001.yml rule=sum:job level=DEBUG msg="Found alerting rule" path=rules/0001.yml alert=Down lines=7-9 level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/0001.yml rule=Down -- rules/0001.yml -- # pint file/snooze 2099-11-28T10:24:18Z promql/aggregate(job:true) # pint file/snooze 2099-11-28T10:24:18Z alerts/for -- record: sum-job +- record: sum:job expr: sum(foo) - alert: Down diff --git a/cmd/pint/tests/0166_invalid_label.txt b/cmd/pint/tests/0166_invalid_label.txt new file mode 100644 index 00000000..d076f5bd --- /dev/null +++ b/cmd/pint/tests/0166_invalid_label.txt @@ -0,0 +1,26 @@ +pint.error --no-color lint rules +! stdout . +cmp stderr stderr.txt + +-- stderr.txt -- +level=INFO msg="Finding all rules to check" paths=["rules"] +rules/1.yaml:7 Fatal: This rule is not a valid Prometheus rule: `invalid annotation name: {{ $value }}`. (yaml/parse) + 7 | "{{ $value }}": "down" + +rules/1.yaml:11 Fatal: This rule is not a valid Prometheus rule: `invalid label name: {{ $value }}`. (yaml/parse) + 11 | "{{ $value }}": "down" + +level=INFO msg="Problems found" Fatal=2 +level=ERROR msg="Fatal error" err="found 1 problem(s) with severity Bug or higher" +-- rules/1.yaml -- +groups: +- name: g1 + rules: + - alert: Service Down + expr: up == 0 + annotations: + "{{ $value }}": "down" + - alert: Service Down + expr: up == 0 + labels: + "{{ $value }}": "down" diff --git a/docs/changelog.md b/docs/changelog.md index b7eb48d3..54cec612 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ ### Changed - A large part of rule parsing code was refactored and more problems will now be deduplicated. +- Improved validation of labels and annotations. ## v0.53.0 diff --git a/internal/checks/alerts_external_labels_test.go b/internal/checks/alerts_external_labels_test.go index b1bef41a..39fa48fa 100644 --- a/internal/checks/alerts_external_labels_test.go +++ b/internal/checks/alerts_external_labels_test.go @@ -28,11 +28,11 @@ func TestAlertsExternalLabelsCountCheck(t *testing.T) { expr: up{job="foo"} == 0 annotations: summary: "{{ $labels.job }} is down" - "{{.ExternalLabels.cluster}}": "This is {{ .ExternalLabels.cluster }} cluster" + cluster: "This is {{ .ExternalLabels.cluster }} cluster" labels: job: "{{ $labels.job }}" - cluster: "{{ $externalLabels.cluster }} / {{ $externalLabels.cluster }}" - "{{ $externalLabels.cluster }}": "{{ $externalLabels.cluster }}" + twice: "{{ $externalLabels.cluster }} / {{ $externalLabels.cluster }}" + cluster: "{{ $externalLabels.cluster }}" ` testCases := []checkTest{ @@ -136,26 +136,6 @@ func TestAlertsExternalLabelsCountCheck(t *testing.T) { Details: alertsExternalLabelsDetails("prom", uri), Severity: checks.Bug, }, - { - Lines: parser.LineRange{ - First: 10, - Last: 10, - }, - Reporter: checks.AlertsExternalLabelsCheckName, - Text: alertsExternalLabelsText("prom", uri, "cluster"), - Details: alertsExternalLabelsDetails("prom", uri), - Severity: checks.Bug, - }, - { - Lines: parser.LineRange{ - First: 6, - Last: 6, - }, - Reporter: checks.AlertsExternalLabelsCheckName, - Text: alertsExternalLabelsText("prom", uri, "cluster"), - Details: alertsExternalLabelsDetails("prom", uri), - Severity: checks.Bug, - }, { Lines: parser.LineRange{ First: 6, diff --git a/internal/checks/alerts_template.go b/internal/checks/alerts_template.go index 1cf322ab..e8dbf3c5 100644 --- a/internal/checks/alerts_template.go +++ b/internal/checks/alerts_template.go @@ -158,19 +158,6 @@ func (c TemplateCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ Severity: Fatal, }) } - // check key - for _, msg := range checkForValueInLabels(label.Key.Value, label.Key.Value) { - problems = append(problems, Problem{ - Lines: parser.LineRange{ - First: label.Key.Lines.First, - Last: label.Value.Lines.Last, - }, - Reporter: c.Reporter(), - Text: msg, - Severity: Bug, - }) - } - // check value for _, msg := range checkForValueInLabels(label.Key.Value, label.Value.Value) { problems = append(problems, Problem{ Lines: parser.LineRange{ diff --git a/internal/checks/alerts_template_test.go b/internal/checks/alerts_template_test.go index c039fe81..6877a280 100644 --- a/internal/checks/alerts_template_test.go +++ b/internal/checks/alerts_template_test.go @@ -120,44 +120,6 @@ func TestTemplateCheck(t *testing.T) { prometheus: noProm, problems: noProblems, }, - { - description: "{{ $value}} in label key", - content: "- alert: foo\n expr: sum(foo)\n labels:\n foo: bar\n '{{ $value}}': bar\n", - checker: newTemplateCheck, - prometheus: noProm, - problems: func(_ string) []checks.Problem { - return []checks.Problem{ - { - Lines: parser.LineRange{ - First: 5, - Last: 5, - }, - Reporter: checks.TemplateCheckName, - Text: "Using `$value` in labels will generate a new alert on every value change, move it to annotations.", - Severity: checks.Bug, - }, - } - }, - }, - { - description: "{{ $value }} in label key", - content: "- alert: foo\n expr: sum(foo)\n labels:\n foo: bar\n '{{ $value }}': bar\n", - checker: newTemplateCheck, - prometheus: noProm, - problems: func(_ string) []checks.Problem { - return []checks.Problem{ - { - Lines: parser.LineRange{ - First: 5, - Last: 5, - }, - Reporter: checks.TemplateCheckName, - Text: "Using `$value` in labels will generate a new alert on every value change, move it to annotations.", - Severity: checks.Bug, - }, - } - }, - }, { description: "{{$value}} in label value", content: "- alert: foo\n expr: sum(foo)\n labels:\n foo: bar\n baz: '{{$value}}'\n", diff --git a/internal/config/__snapshots__/config_test.snap b/internal/config/__snapshots__/config_test.snap index 85d47207..530699d3 100755 --- a/internal/config/__snapshots__/config_test.snap +++ b/internal/config/__snapshots__/config_test.snap @@ -2573,5153 +2573,3 @@ ] } --- - -[TestGetChecksForRule/defaults - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {} -} ---- - -[TestGetChecksForRule/single_prometheus_server - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/multiple_URIs - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "failover": [ - "http://localhost/1", - "http://localhost/2" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_disable_all_checks_via_comment - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "alerts/external_labels" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_path_mismatch - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "foo.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_include_&_exclude - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - ".*" - ], - "exclude": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_excluded - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "exclude": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_path_match - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/multiple_prometheus_servers - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "ignore", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "foo.+" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_empty_rule - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - {} - ] -} ---- - -[TestGetChecksForRule/rule_with_aggregate_checks - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "aggregate": [ - { - "name": ".+", - "severity": "bug", - "keep": [ - "job" - ] - }, - { - "name": ".+", - "severity": "bug", - "strip": [ - "instance", - "rack" - ] - } - ] - } - ] -} ---- - -[TestGetChecksForRule/multiple_checks_and_disable_comment - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "aggregate": [ - { - "name": ".+", - "severity": "bug", - "keep": [ - "job" - ] - }, - { - "name": ".+", - "severity": "bug", - "strip": [ - "instance", - "rack" - ] - } - ] - } - ] -} ---- - -[TestGetChecksForRule/prometheus_check_without_prometheus_server - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "cost": { - "severity": "warning", - "maxSeries": 10000 - } - } - ] -} ---- - -[TestGetChecksForRule/prometheus_check_with_prometheus_servers_and_disable_comment - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "cost": {} - } - ] -} ---- - -[TestGetChecksForRule/duplicated_rules - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "label": [ - { - "key": "team", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "severity": "bug", - "required": true - } - ], - "label": [ - { - "key": "team", - "severity": "warning" - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "value": "foo.+", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "token": "\\w+", - "value": "foo.+", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/multiple_cost_checks - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "cost": { - "severity": "info" - } - }, - { - "cost": { - "severity": "warning", - "maxSeries": 10000 - } - }, - { - "cost": { - "severity": "bug", - "maxSeries": 20000 - } - } - ] -} ---- - -[TestGetChecksForRule/reject_rules - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "reject": [ - { - "key": "http://.+", - "label_keys": true, - "label_values": true - }, - { - "key": ".* +.*", - "label_keys": true, - "annotation_keys": true - }, - { - "severity": "bug", - "annotation_values": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_type_mismatch - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_no_label - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_label_mismatch - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_label_match - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_no_annotation - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_annotation_mismatch - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_annotation_match - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "token": "\\w+", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/checks_disabled_via_config - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "promql/rate", - "promql/vector_matching", - "promql/range_query", - "rule/duplicate", - "labels/conflict" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/single_check_enabled_via_config - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": {}, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/two_checks_enabled_via_config - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/rule_with_ignore_block_/_mismatch - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "ignore": [ - { - "path": "foo.xml" - } - ], - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/rule_with_ignore_block_/_match - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "ignore": [ - { - "path": "rules.yml" - } - ], - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_not_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#01 - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#02 - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#03 - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_recording_rules_/_not_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "!= 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003c 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_not_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003c 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_recording_rules_/_passing - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003e 0" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/link - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "link": [ - { - "key": "https?://(.+)", - "uri": "http://localhost/$1", - "timeout": "10s", - "headers": { - "X-Auth": "xxx" - }, - "severity": "bug" - } - ] - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_disable_checks_via_file/disable_comment - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "alerts/external_labels" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_snoozed_checks_via_comment - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "promql/regexp" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_expired_snooze - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "promql/regexp" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/tag_disables_all_prometheus_checks - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo", - "disable", - "bar" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "2m0s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom3", - "uri": "http://localhost/3", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/tag_snoozes_all_prometheus_checks - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo", - "disable", - "bar" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "2m0s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom3", - "uri": "http://localhost/3", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/alerts/count_defaults - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1d", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/alerts/count_full - 2] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1d", - "step": "1m", - "resolve": "5m", - "severity": "bug", - "minCount": 100 - } - } - ] -} ---- - -[TestGetChecksForRule/defaults - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {} -} ---- - -[TestGetChecksForRule/single_prometheus_server - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/multiple_URIs - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "failover": [ - "http://localhost/1", - "http://localhost/2" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_disable_all_checks_via_comment - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "alerts/external_labels" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_path_mismatch - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "foo.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_include_&_exclude - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - ".*" - ], - "exclude": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_excluded - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "exclude": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_prometheus_server_/_path_match - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/multiple_prometheus_servers - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "ignore", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "foo.+" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/single_empty_rule - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - {} - ] -} ---- - -[TestGetChecksForRule/rule_with_aggregate_checks - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "aggregate": [ - { - "name": ".+", - "severity": "bug", - "keep": [ - "job" - ] - }, - { - "name": ".+", - "severity": "bug", - "strip": [ - "instance", - "rack" - ] - } - ] - } - ] -} ---- - -[TestGetChecksForRule/multiple_checks_and_disable_comment - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "aggregate": [ - { - "name": ".+", - "severity": "bug", - "keep": [ - "job" - ] - }, - { - "name": ".+", - "severity": "bug", - "strip": [ - "instance", - "rack" - ] - } - ] - } - ] -} ---- - -[TestGetChecksForRule/prometheus_check_without_prometheus_server - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "cost": { - "severity": "warning", - "maxSeries": 10000 - } - } - ] -} ---- - -[TestGetChecksForRule/prometheus_check_with_prometheus_servers_and_disable_comment - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "cost": {} - } - ] -} ---- - -[TestGetChecksForRule/duplicated_rules - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "label": [ - { - "key": "team", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "severity": "bug", - "required": true - } - ], - "label": [ - { - "key": "team", - "severity": "warning" - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "value": "foo.+", - "severity": "bug", - "required": true - } - ] - }, - { - "annotation": [ - { - "key": "summary", - "token": "\\w+", - "value": "foo.+", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/multiple_cost_checks - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "cost": { - "severity": "info" - } - }, - { - "cost": { - "severity": "warning", - "maxSeries": 10000 - } - }, - { - "cost": { - "severity": "bug", - "maxSeries": 20000 - } - } - ] -} ---- - -[TestGetChecksForRule/reject_rules - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "reject": [ - { - "key": "http://.+", - "label_keys": true, - "label_values": true - }, - { - "key": ".* +.*", - "label_keys": true, - "annotation_keys": true - }, - { - "severity": "bug", - "annotation_values": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_type_mismatch - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_no_label - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_label_mismatch - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_label_match_/_label_match - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "label": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_no_annotation - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_annotation_mismatch - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/rule_with_annotation_match_/_annotation_match - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "annotation": { - "key": "cluster", - "value": "prod" - }, - "kind": "alerting" - } - ], - "label": [ - { - "key": "priority", - "token": "\\w+", - "value": "(1|2|3|4|5)", - "severity": "bug", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/checks_disabled_via_config - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "promql/rate", - "promql/vector_matching", - "promql/range_query", - "rule/duplicate", - "labels/conflict" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/single_check_enabled_via_config - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": {}, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/two_checks_enabled_via_config - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/rule_with_ignore_block_/_mismatch - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "ignore": [ - { - "path": "foo.xml" - } - ], - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/rule_with_ignore_block_/_match - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "promql/syntax", - "alerts/count" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "include": [ - "rules.yml" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "ignore": [ - { - "path": "rules.yml" - } - ], - "alerts": { - "range": "1h", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_not_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#01 - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#02 - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_passing#03 - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "keep_firing_for": "\u003e 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_match_/_recording_rules_/_not_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "match": [ - { - "for": "!= 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003c 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_not_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003c 15m" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/for_ignore_/_recording_rules_/_passing - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "ignore": [ - { - "for": "\u003e 0" - } - ], - "annotation": [ - { - "key": "summary", - "required": true - } - ] - } - ] -} ---- - -[TestGetChecksForRule/link - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "rules": [ - { - "link": [ - { - "key": "https?://(.+)", - "uri": "http://localhost/$1", - "timeout": "10s", - "headers": { - "X-Auth": "xxx" - }, - "severity": "bug" - } - ] - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_disable_checks_via_file/disable_comment - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "alerts/external_labels" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_snoozed_checks_via_comment - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "promql/regexp" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/two_prometheus_servers_/_expired_snooze - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ], - "disabled": [ - "alerts/template", - "promql/regexp" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/tag_disables_all_prometheus_checks - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo", - "disable", - "bar" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "2m0s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom3", - "uri": "http://localhost/3", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/tag_snoozes_all_prometheus_checks - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom1", - "uri": "http://localhost/1", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo", - "disable", - "bar" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom2", - "uri": "http://localhost/2", - "timeout": "2m0s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - }, - { - "name": "prom3", - "uri": "http://localhost/3", - "timeout": "2m0s", - "uptime": "up", - "tags": [ - "foo" - ], - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ] -} ---- - -[TestGetChecksForRule/alerts/count_defaults - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1d", - "step": "1m", - "resolve": "5m" - } - } - ] -} ---- - -[TestGetChecksForRule/alerts/count_full - 3] -{ - "ci": { - "baseBranch": "master", - "maxCommits": 20 - }, - "parser": {}, - "checks": { - "enabled": [ - "alerts/annotation", - "alerts/count", - "alerts/external_labels", - "alerts/for", - "alerts/template", - "labels/conflict", - "promql/aggregate", - "alerts/comparison", - "promql/fragile", - "promql/range_query", - "promql/rate", - "promql/regexp", - "promql/syntax", - "promql/vector_matching", - "query/cost", - "promql/series", - "rule/dependency", - "rule/duplicate", - "rule/for", - "rule/label", - "rule/link", - "rule/reject" - ] - }, - "owners": {}, - "prometheus": [ - { - "name": "prom", - "uri": "http://localhost", - "timeout": "1s", - "uptime": "up", - "concurrency": 16, - "rateLimit": 100, - "required": false - } - ], - "rules": [ - { - "alerts": { - "range": "1d", - "step": "1m", - "resolve": "5m", - "severity": "bug", - "minCount": 100 - } - } - ] -} ---- diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 490cc3cc..a14d945e 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -28,6 +28,9 @@ var ignoredErrors = []string{ "could not parse expression: ", "cannot unmarshal !!seq into rulefmt.ruleGroups", ": template: __", + "invalid label name: ", + "invalid annotation name: ", + "invalid recording rule name: ", } type FileIgnoreError struct { diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 091909f3..c76f9634 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -7,6 +7,8 @@ import ( "gopkg.in/yaml.v3" + "github.com/prometheus/common/model" + "github.com/cloudflare/pint/internal/comments" ) @@ -245,6 +247,36 @@ func parseRule(content []byte, node *yaml.Node, offset int) (rule Rule, _ bool, } return rule, false, err } + if recordPart != nil && forPart != nil { + rule = Rule{ + Lines: lines, + Error: ParseError{ + Line: forPart.Lines.First, + Err: fmt.Errorf("invalid field '%s' in recording rule", forKey), + }, + } + return rule, false, err + } + if recordPart != nil && keepFiringForPart != nil { + rule = Rule{ + Lines: lines, + Error: ParseError{ + Line: keepFiringForPart.Lines.First, + Err: fmt.Errorf("invalid field '%s' in recording rule", keepFiringForKey), + }, + } + return rule, false, err + } + if recordPart != nil && annotationsPart != nil { + rule = Rule{ + Lines: lines, + Error: ParseError{ + Line: annotationsPart.Lines.First, + Err: fmt.Errorf("invalid field '%s' in recording rule", annotationsKey), + }, + } + return rule, false, err + } if r, ok := ensureRequiredKeys(lines, recordKey, recordPart, exprPart); !ok { return r, false, err } @@ -266,6 +298,53 @@ func parseRule(content []byte, node *yaml.Node, offset int) (rule Rule, _ bool, return rule, false, err } + if recordPart != nil && !model.IsValidMetricName(model.LabelValue(recordPart.Value)) { + return Rule{ + Lines: lines, + Error: ParseError{ + Line: recordPart.Lines.First, + Err: fmt.Errorf("invalid recording rule name: %s", recordPart.Value), + }, + }, false, err + } + + if (recordPart != nil || alertPart != nil) && labelsPart != nil { + for _, lab := range labelsPart.Items { + if !model.LabelName(lab.Key.Value).IsValid() || lab.Key.Value == model.MetricNameLabel { + return Rule{ + Lines: lines, + Error: ParseError{ + Line: lab.Key.Lines.First, + Err: fmt.Errorf("invalid label name: %s", lab.Key.Value), + }, + }, false, err + } + if !model.LabelValue(lab.Value.Value).IsValid() { + return Rule{ + Lines: lines, + Error: ParseError{ + Line: lab.Key.Lines.First, + Err: fmt.Errorf("invalid label value: %s", lab.Value.Value), + }, + }, false, err + } + } + } + + if alertPart != nil && annotationsPart != nil { + for _, ann := range annotationsPart.Items { + if !model.LabelName(ann.Key.Value).IsValid() { + return Rule{ + Lines: lines, + Error: ParseError{ + Line: ann.Key.Lines.First, + Err: fmt.Errorf("invalid annotation name: %s", ann.Key.Value), + }, + }, false, err + } + } + } + if recordPart != nil && exprPart != nil { rule = Rule{ Lines: lines, diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 8e7acf1c..75bb6094 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -522,8 +522,7 @@ groups: annotations: uri: https://docs.example.com/down.html -- record: > - foo +- record: foo expr: |- bar / @@ -596,15 +595,15 @@ groups: }, }, { - Lines: parser.LineRange{First: 11, Last: 17}, + Lines: parser.LineRange{First: 11, Last: 16}, RecordingRule: &parser.RecordingRule{ Record: parser.YamlNode{ - Lines: parser.LineRange{First: 11, Last: 12}, - Value: "foo\n", + Lines: parser.LineRange{First: 11, Last: 11}, + Value: "foo", }, Expr: parser.PromQLExpr{ Value: &parser.YamlNode{ - Lines: parser.LineRange{First: 13, Last: 16}, + Lines: parser.LineRange{First: 12, Last: 15}, Value: "bar\n/\nbaz > 1", }, Query: &parser.PromQLNode{ @@ -621,9 +620,9 @@ groups: }, }, Labels: &parser.YamlMap{ - Lines: parser.LineRange{First: 17, Last: 17}, + Lines: parser.LineRange{First: 16, Last: 16}, Key: &parser.YamlNode{ - Lines: parser.LineRange{First: 17, Last: 17}, + Lines: parser.LineRange{First: 16, Last: 16}, Value: "labels", }, }, @@ -1403,6 +1402,138 @@ data: }, }, }, + { + content: []byte(` +- record: invalid metric name + expr: bar +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 3}, + Error: parser.ParseError{Err: fmt.Errorf("invalid recording rule name: invalid metric name"), Line: 2}, + }, + }, + }, + { + content: []byte(` +- record: foo + expr: bar + labels: + "foo bar": yes +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid label name: foo bar"), Line: 5}, + }, + }, + }, + { + content: []byte(` +- alert: foo + expr: bar + labels: + "foo bar": yes +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid label name: foo bar"), Line: 5}, + }, + }, + }, + { + content: []byte(` +- alert: foo + expr: bar + labels: + "{{ $value }}": yes +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid label name: {{ $value }}"), Line: 5}, + }, + }, + }, + { + content: []byte(` +- alert: foo + expr: bar + annotations: + "foo bar": yes +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid annotation name: foo bar"), Line: 5}, + }, + }, + }, + { + content: []byte(` +- alert: foo + expr: bar + labels: + foo: ` + string("\xed\xbf\xbf")), + // Label values are invalid only if they aren't valid UTF-8 strings + // which also makes them unparsable by YAML. + shouldError: true, + }, + { + content: []byte(` +- alert: foo + expr: bar + annotations: + "{{ $value }}": yes +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid annotation name: {{ $value }}"), Line: 5}, + }, + }, + }, + { + content: []byte(` +- record: foo + expr: bar + keep_firing_for: 5m +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 4}, + Error: parser.ParseError{Err: fmt.Errorf("invalid field 'keep_firing_for' in recording rule"), Line: 4}, + }, + }, + }, + { + content: []byte(` +- record: foo + expr: bar + for: 5m +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 4}, + Error: parser.ParseError{Err: fmt.Errorf("invalid field 'for' in recording rule"), Line: 4}, + }, + }, + }, + { + content: []byte(` +- record: foo + expr: bar + annotations: + foo: bar +`), + output: []parser.Rule{ + { + Lines: parser.LineRange{First: 2, Last: 5}, + Error: parser.ParseError{Err: fmt.Errorf("invalid field 'annotations' in recording rule"), Line: 4}, + }, + }, + }, } alwaysEqual := cmp.Comparer(func(_, _ interface{}) bool { return true })