diff --git a/cmd/pint/lint.go b/cmd/pint/lint.go index 0c240d30..1a15d25e 100644 --- a/cmd/pint/lint.go +++ b/cmd/pint/lint.go @@ -189,10 +189,7 @@ func verifyOwners(entries []discovery.Entry, allowedOwners []*regexp.Regexp) (re } if entry.Owner == "" { reports = append(reports, reporter.Report{ - Path: discovery.Path{ - Name: entry.Path.Name, - SymlinkTarget: entry.Path.SymlinkTarget, - }, + Path: entry.Path, ModifiedLines: entry.ModifiedLines, Rule: entry.Rule, Problem: checks.Problem{ @@ -211,10 +208,7 @@ func verifyOwners(entries []discovery.Entry, allowedOwners []*regexp.Regexp) (re } } reports = append(reports, reporter.Report{ - Path: discovery.Path{ - Name: entry.Path.Name, - SymlinkTarget: entry.Path.SymlinkTarget, - }, + Path: entry.Path, ModifiedLines: entry.ModifiedLines, Rule: entry.Rule, Problem: checks.Problem{ diff --git a/cmd/pint/scan.go b/cmd/pint/scan.go index f588a79a..5b5161ab 100644 --- a/cmd/pint/scan.go +++ b/cmd/pint/scan.go @@ -16,6 +16,7 @@ import ( ) func checkRules(ctx context.Context, workers int, isOffline bool, gen *config.PrometheusGenerator, cfg config.Config, entries []discovery.Entry) (summary reporter.Summary, err error) { + slog.Info("Checking Prometheus rules", slog.Int("entries", len(entries)), slog.Int("workers", workers), slog.Bool("online", !isOffline)) if isOffline { slog.Info("Offline mode, skipping Prometheus discovery") } else { @@ -153,10 +154,7 @@ func scanWorker(ctx context.Context, jobs <-chan scanJob, results chan<- reporte checkDuration.WithLabelValues(job.check.Reporter()).Observe(time.Since(start).Seconds()) for _, problem := range problems { results <- reporter.Report{ - Path: discovery.Path{ - Name: job.entry.Path.Name, - SymlinkTarget: job.entry.Path.SymlinkTarget, - }, + Path: job.entry.Path, ModifiedLines: job.entry.ModifiedLines, Rule: job.entry.Rule, Problem: problem, diff --git a/cmd/pint/tests/0001_match_path.txt b/cmd/pint/tests/0001_match_path.txt index 368d1c7e..adf4cd37 100644 --- a/cmd/pint/tests/0001_match_path.txt +++ b/cmd/pint/tests/0001_match_path.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/0002.yml:2 Bug: `job` label is required and should be preserved when aggregating `^.+$` rules, remove job from `without()`. (promql/aggregate) 2 | expr: sum(foo) without(job) diff --git a/cmd/pint/tests/0003_lint_workdir.txt b/cmd/pint/tests/0003_lint_workdir.txt index e455a25d..fd3e12a0 100644 --- a/cmd/pint/tests/0003_lint_workdir.txt +++ b/cmd/pint/tests/0003_lint_workdir.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=17 workers=10 online=true rules/0001.yml:2 Warning: `job` label is required and should be preserved when aggregating `^.+$` rules, remove job from `without()`. (promql/aggregate) 2 | expr: sum(rate(fl_cf_html_bytes_in[10m])) WITHOUT (colo_id, instance, node_type, region, node_status, job, colo_name) diff --git a/cmd/pint/tests/0004_fail_invalid_yaml.txt b/cmd/pint/tests/0004_fail_invalid_yaml.txt index bfb02d3c..1dddd155 100644 --- a/cmd/pint/tests/0004_fail_invalid_yaml.txt +++ b/cmd/pint/tests/0004_fail_invalid_yaml.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 4: did not find expected key" path=rules/bad.yaml lines=1-7 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/bad.yaml:4 Fatal: did not find expected key (yaml/parse) 4 | diff --git a/cmd/pint/tests/0005_false_positive.txt b/cmd/pint/tests/0005_false_positive.txt index 9467adb8..4edf5581 100644 --- a/cmd/pint/tests/0005_false_positive.txt +++ b/cmd/pint/tests/0005_false_positive.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- rules/0001.yml -- - record: "colo:test1" expr: topk(6, sum(rate(edgeworker_subrequest_errorCount{cordon="free"}[5m])) BY (zoneId,job)) diff --git a/cmd/pint/tests/0006_rr_labels.txt b/cmd/pint/tests/0006_rr_labels.txt index 31378d24..0c25c5c4 100644 --- a/cmd/pint/tests/0006_rr_labels.txt +++ b/cmd/pint/tests/0006_rr_labels.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/0001.yml:8 Fatal: This rule is not a valid Prometheus rule: `incomplete rule, no alert or record key`. (yaml/parse) 8 | - expr: sum(foo) diff --git a/cmd/pint/tests/0007_alerts.txt b/cmd/pint/tests/0007_alerts.txt index 8d6bfe7a..b6212be1 100644 --- a/cmd/pint/tests/0007_alerts.txt +++ b/cmd/pint/tests/0007_alerts.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=6 workers=10 online=true rules/0001.yml:1-2 Warning: `severity` label is required. (rule/label) 1 | - alert: Always 2 | expr: up diff --git a/cmd/pint/tests/0008_recording_rule_prometheus.txt b/cmd/pint/tests/0008_recording_rule_prometheus.txt index b78654af..77fbb7c9 100644 --- a/cmd/pint/tests/0008_recording_rule_prometheus.txt +++ b/cmd/pint/tests/0008_recording_rule_prometheus.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/0001.yml:5 Warning: `job` label is required and should be preserved when aggregating `^.+$` rules, use `by(job, ...)`. (promql/aggregate) 5 | expr: sum by (instance) (http_inprogress_requests) diff --git a/cmd/pint/tests/0009_alerting_rule_prometheus.txt b/cmd/pint/tests/0009_alerting_rule_prometheus.txt index 907598f8..36e28def 100644 --- a/cmd/pint/tests/0009_alerting_rule_prometheus.txt +++ b/cmd/pint/tests/0009_alerting_rule_prometheus.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/0001.yml:11-13 Bug: `link` annotation is required. (alerts/annotation) 11 | annotations: 12 | summary: "Instance {{ $labels.instance }} down" diff --git a/cmd/pint/tests/0010_syntax_check.txt b/cmd/pint/tests/0010_syntax_check.txt index a2f3b42e..5b1f1209 100644 --- a/cmd/pint/tests/0010_syntax_check.txt +++ b/cmd/pint/tests/0010_syntax_check.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 6: did not find expected '-' indicator" path=rules/1.yaml lines=1-12 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/1.yaml:6 Fatal: did not find expected '-' indicator (yaml/parse) 6 | diff --git a/cmd/pint/tests/0011_ignore_rules.txt b/cmd/pint/tests/0011_ignore_rules.txt index 328cbd75..33681547 100644 --- a/cmd/pint/tests/0011_ignore_rules.txt +++ b/cmd/pint/tests/0011_ignore_rules.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=10 workers=10 online=true rules/1.yaml:5 Fatal: Prometheus failed to parse the query with this PromQL error: unexpected right parenthesis ')'. (promql/syntax) 5 | expr: sum(errors_total) by ) diff --git a/cmd/pint/tests/0012_issue_20.txt b/cmd/pint/tests/0012_issue_20.txt index 5a7bb374..672c18bb 100644 --- a/cmd/pint/tests/0012_issue_20.txt +++ b/cmd/pint/tests/0012_issue_20.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=WARN msg="Tried to read more lines than present in the source file, this is likely due to ' ' usage in some rules, see https://github.com/cloudflare/pint/issues/20 for details" path=rules/1.yaml rules/1.yaml:9-13 Warning: `runbook_url` annotation is required. (alerts/annotation) diff --git a/cmd/pint/tests/0014_issue49_2.txt b/cmd/pint/tests/0014_issue49_2.txt index 84e2e0c4..d603a62a 100644 --- a/cmd/pint/tests/0014_issue49_2.txt +++ b/cmd/pint/tests/0014_issue49_2.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true -- rules/0001.yaml -- - record: down expr: up == 0 diff --git a/cmd/pint/tests/0018_match_alerting.txt b/cmd/pint/tests/0018_match_alerting.txt index 60a8293b..4d61a8f7 100644 --- a/cmd/pint/tests/0018_match_alerting.txt +++ b/cmd/pint/tests/0018_match_alerting.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:recording lines=1-2 state=noop 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=colo:recording diff --git a/cmd/pint/tests/0019_match_recording.txt b/cmd/pint/tests/0019_match_recording.txt index 77bc6376..13b9ba2e 100644 --- a/cmd/pint/tests/0019_match_recording.txt +++ b/cmd/pint/tests/0019_match_recording.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:recording lines=1-2 state=noop 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=colo:recording diff --git a/cmd/pint/tests/0020_ignore_kind.txt b/cmd/pint/tests/0020_ignore_kind.txt index 07d33482..30d15b30 100644 --- a/cmd/pint/tests/0020_ignore_kind.txt +++ b/cmd/pint/tests/0020_ignore_kind.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:recording lines=4-5 state=noop 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=colo:recording diff --git a/cmd/pint/tests/0022_ignore_multi.txt b/cmd/pint/tests/0022_ignore_multi.txt index d26c6d08..775df8c6 100644 --- a/cmd/pint/tests/0022_ignore_multi.txt +++ b/cmd/pint/tests/0022_ignore_multi.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true rules/1.yaml:2 Warning: `dropped` label should be removed when aggregating `^.+$` rules, remove dropped from `by()`. (promql/aggregate) 2 | expr: sum(errors_total) by(keep,dropped) diff --git a/cmd/pint/tests/0024_color_output.txt b/cmd/pint/tests/0024_color_output.txt index ee51c1ab..e4cb8453 100644 --- a/cmd/pint/tests/0024_color_output.txt +++ b/cmd/pint/tests/0024_color_output.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=14 workers=10 online=true rules/0001.yml:2 Warning: `job` label is required and should be preserved when aggregating `^.+$` rules, remove job from `without()`. (promql/aggregate)  2 | expr: sum(rate(fl_cf_html_bytes_in[10m])) WITHOUT (colo_id, instance, node_type, region, node_status, job, colo_name)  diff --git a/cmd/pint/tests/0027_ci_branch.txt b/cmd/pint/tests/0027_ci_branch.txt index 1ec9ed53..c6799167 100644 --- a/cmd/pint/tests/0027_ci_branch.txt +++ b/cmd/pint/tests/0027_ci_branch.txt @@ -22,6 +22,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=INFO msg="Problems found" Fatal=1 rules.yml:2 Fatal: Prometheus failed to parse the query with this PromQL error: unexpected identifier "bi". (promql/syntax) 2 | expr: sum(foo) bi(job) diff --git a/cmd/pint/tests/0037_disable_checks.txt b/cmd/pint/tests/0037_disable_checks.txt index a90642d4..0b45331e 100644 --- a/cmd/pint/tests/0037_disable_checks.txt +++ b/cmd/pint/tests/0037_disable_checks.txt @@ -10,6 +10,7 @@ level=DEBUG msg="File parsed" path=rules/0001.yml rules=3 level=DEBUG msg="Glob finder completed" count=3 level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] level=DEBUG msg="Starting query workers" name=prom uri=http://127.0.0.1 workers=16 +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true 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 state=noop 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)","alerts/absent(prom)"] path=rules/0001.yml rule=default-for diff --git a/cmd/pint/tests/0038_disable_checks_regex.txt b/cmd/pint/tests/0038_disable_checks_regex.txt index 6013e580..d451e34b 100644 --- a/cmd/pint/tests/0038_disable_checks_regex.txt +++ b/cmd/pint/tests/0038_disable_checks_regex.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true rules/0001.yml:6 Warning: `job` label is required and should be preserved when aggregating `^.+$` rules, use `by(job, ...)`. (promql/aggregate) 6 | expr: sum(foo) diff --git a/cmd/pint/tests/0039_prom_selected_path.txt b/cmd/pint/tests/0039_prom_selected_path.txt index 8a076e8d..f5e6c83c 100644 --- a/cmd/pint/tests/0039_prom_selected_path.txt +++ b/cmd/pint/tests/0039_prom_selected_path.txt @@ -10,6 +10,7 @@ level=DEBUG msg="File parsed" path=rules/0001.yml rules=3 level=DEBUG msg="Glob finder completed" count=3 level=INFO msg="Configured new Prometheus server" name=disabled uris=1 uptime=up tags=[] include=["^invalid/.+$"] exclude=["^invalid/rules/.+$"] level=DEBUG msg="Starting query workers" name=disabled uri=http://127.0.0.1:123 workers=16 +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=1 level=DEBUG msg="Found alerting rule" path=rules/0001.yml alert=first lines=1-3 state=noop 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=first diff --git a/cmd/pint/tests/0040_rule_match_label.txt b/cmd/pint/tests/0040_rule_match_label.txt index ba3d3018..d0b158dd 100644 --- a/cmd/pint/tests/0040_rule_match_label.txt +++ b/cmd/pint/tests/0040_rule_match_label.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/rules.yml rules=4 level=DEBUG msg="Glob finder completed" count=4 +level=INFO msg="Checking Prometheus rules" entries=4 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/rules.yml record=ignore lines=1-2 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/rules.yml rule=ignore diff --git a/cmd/pint/tests/0052_match_multiple.txt b/cmd/pint/tests/0052_match_multiple.txt index 31be1196..a28ed47d 100644 --- a/cmd/pint/tests/0052_match_multiple.txt +++ b/cmd/pint/tests/0052_match_multiple.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:recording lines=4-5 state=noop 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=colo:recording diff --git a/cmd/pint/tests/0053_ignore_multiple.txt b/cmd/pint/tests/0053_ignore_multiple.txt index aca74731..20cd4f1b 100644 --- a/cmd/pint/tests/0053_ignore_multiple.txt +++ b/cmd/pint/tests/0053_ignore_multiple.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:recording lines=4-5 state=noop 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=colo:recording diff --git a/cmd/pint/tests/0058_templated_check.txt b/cmd/pint/tests/0058_templated_check.txt index e4dc04db..497dd515 100644 --- a/cmd/pint/tests/0058_templated_check.txt +++ b/cmd/pint/tests/0058_templated_check.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true rules/0001.yml:4-6 Bug: `alert_for` annotation is required. (alerts/annotation) 4 | - alert: Instance Is Down 2 5 | expr: up == 0 diff --git a/cmd/pint/tests/0060_ci_noop.txt b/cmd/pint/tests/0060_ci_noop.txt index 34e02263..f153fa80 100644 --- a/cmd/pint/tests/0060_ci_noop.txt +++ b/cmd/pint/tests/0060_ci_noop.txt @@ -31,6 +31,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Problems found" Fatal=1 b.yml:2 Fatal: Prometheus failed to parse the query with this PromQL error: unexpected identifier "bi". (promql/syntax) 2 | expr: sum(foo) bi() diff --git a/cmd/pint/tests/0063_lint_offline.txt b/cmd/pint/tests/0063_lint_offline.txt index 111b6d50..976589f5 100644 --- a/cmd/pint/tests/0063_lint_offline.txt +++ b/cmd/pint/tests/0063_lint_offline.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=disabled uris=1 uptime=up tags=[] include=["^invalid/.+$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=false level=INFO msg="Offline mode, skipping Prometheus discovery" -- rules/ok.yml -- - record: sum:foo diff --git a/cmd/pint/tests/0066_lint_owner.txt b/cmd/pint/tests/0066_lint_owner.txt index 35b31586..50363298 100644 --- a/cmd/pint/tests/0066_lint_owner.txt +++ b/cmd/pint/tests/0066_lint_owner.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=5 workers=10 online=true rules/1.yml:4-5 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: No Owner 5 | expr: up > 0 diff --git a/cmd/pint/tests/0067_relaxed.txt b/cmd/pint/tests/0067_relaxed.txt index a426e52b..9c890e7f 100644 --- a/cmd/pint/tests/0067_relaxed.txt +++ b/cmd/pint/tests/0067_relaxed.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 2: top level field must be a groups key, got list" path=rules/strict.yml lines=1-4 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/strict.yml:2 Fatal: top level field must be a groups key, got list (yaml/parse) 2 | - alert: No Owner diff --git a/cmd/pint/tests/0073_lint_k8s.txt b/cmd/pint/tests/0073_lint_k8s.txt index a7adb1d0..9370ab27 100644 --- a/cmd/pint/tests/0073_lint_k8s.txt +++ b/cmd/pint/tests/0073_lint_k8s.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=4 workers=10 online=true rules/1.yml:22-23 Bug: `summary` annotation is required. (alerts/annotation) 22 | - alert: Example_High_Restart_Rate 23 | expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 ) diff --git a/cmd/pint/tests/0074_strict_error.txt b/cmd/pint/tests/0074_strict_error.txt index 84a07d5c..c78d4d1b 100644 --- a/cmd/pint/tests/0074_strict_error.txt +++ b/cmd/pint/tests/0074_strict_error.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 2: invalid group key alert" path=rules/strict.yml lines=1-9 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/strict.yml:2 Fatal: invalid group key alert (yaml/parse) 2 | - alert: Conntrack_Table_Almost_Full diff --git a/cmd/pint/tests/0077_strict_error_owner.txt b/cmd/pint/tests/0077_strict_error_owner.txt index d367043a..cfb6c122 100644 --- a/cmd/pint/tests/0077_strict_error_owner.txt +++ b/cmd/pint/tests/0077_strict_error_owner.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true 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: up == 0 diff --git a/cmd/pint/tests/0078_repeated_group.txt b/cmd/pint/tests/0078_repeated_group.txt index c20f1703..0b0e9615 100644 --- a/cmd/pint/tests/0078_repeated_group.txt +++ b/cmd/pint/tests/0078_repeated_group.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 4: duplicated group name" path=rules/strict.yml lines=1-5 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/strict.yml:4 Fatal: duplicated group name (yaml/parse) 4 | - name: foo diff --git a/cmd/pint/tests/0080_lint_online.txt b/cmd/pint/tests/0080_lint_online.txt index c26d60e3..6afdfdc8 100644 --- a/cmd/pint/tests/0080_lint_online.txt +++ b/cmd/pint/tests/0080_lint_online.txt @@ -13,6 +13,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=prometheus_ready tags=[] include=[] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom1 metric=prometheus_ready level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom1 metric=prometheus_ready rules/1.yml:2 Warning: `http_errors_total[2d]` selector is trying to query Prometheus for 2d worth of metrics, but `prom1` Prometheus server at http://127.0.0.1:7080 is configured to only keep 1d of metrics history. (promql/range_query) diff --git a/cmd/pint/tests/0081_rulefmt.txt b/cmd/pint/tests/0081_rulefmt.txt index d6cfa467..2117ec1c 100644 --- a/cmd/pint/tests/0081_rulefmt.txt +++ b/cmd/pint/tests/0081_rulefmt.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/strict.yml:4 Fatal: This rule is not a valid Prometheus rule: `missing expr key`. (yaml/parse) 4 | - record: foo diff --git a/cmd/pint/tests/0086_rulefmt_ignored_errors.txt b/cmd/pint/tests/0086_rulefmt_ignored_errors.txt index 80bf319a..578ff37c 100644 --- a/cmd/pint/tests/0086_rulefmt_ignored_errors.txt +++ b/cmd/pint/tests/0086_rulefmt_ignored_errors.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=5 workers=10 online=true rules/strict.yml:4 Fatal: This rule is not a valid Prometheus rule: `incomplete rule, no alert or record key`. (yaml/parse) 4 | - expr: MissingAlertOrRecord diff --git a/cmd/pint/tests/0087_dedup.txt b/cmd/pint/tests/0087_dedup.txt index e75e121e..0cfb17ab 100644 --- a/cmd/pint/tests/0087_dedup.txt +++ b/cmd/pint/tests/0087_dedup.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/01.yml:5 Warning: Alert query doesn't have any condition, it will always fire if the metric exists. (alerts/comparison) 5 | expr: sum(up{job="bar"}) / sum(foo) / sum(bar) diff --git a/cmd/pint/tests/0088_rule_link.txt b/cmd/pint/tests/0088_rule_link.txt index 371f9e09..ecedfd03 100644 --- a/cmd/pint/tests/0088_rule_link.txt +++ b/cmd/pint/tests/0088_rule_link.txt @@ -12,6 +12,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/1.yml:10 Information: GET request for http://127.0.0.1:7088/404 returned invalid status code: `404 Not Found`. (rule/link) 10 | r404: http://127.0.0.1:7088/404 diff --git a/cmd/pint/tests/0089_lint_min_severity_bug.txt b/cmd/pint/tests/0089_lint_min_severity_bug.txt index 3c875acc..f4c12eac 100644 --- a/cmd/pint/tests/0089_lint_min_severity_bug.txt +++ b/cmd/pint/tests/0089_lint_min_severity_bug.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Problems found" Information=1 level=INFO msg="1 problem(s) not visible because of --min-severity=bug flag" -- rules/0001.yml -- diff --git a/cmd/pint/tests/0090_lint_min_severity_info.txt b/cmd/pint/tests/0090_lint_min_severity_info.txt index e6e75940..6b49a64e 100644 --- a/cmd/pint/tests/0090_lint_min_severity_info.txt +++ b/cmd/pint/tests/0090_lint_min_severity_info.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/0001.yml:7 Information: Using the value of `rate(errors[2m])` inside this annotation might be hard to read, consider using one of humanize template functions to make it more human friendly. (alerts/template) 7 | summary: 'error rate: {{ $value }}' diff --git a/cmd/pint/tests/0091_lint_min_severity_invalid.txt b/cmd/pint/tests/0091_lint_min_severity_invalid.txt index ccf0d13b..7077b781 100644 --- a/cmd/pint/tests/0091_lint_min_severity_invalid.txt +++ b/cmd/pint/tests/0091_lint_min_severity_invalid.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=ERROR msg="Fatal error" err="invalid --min-severity value: unknown severity: xxx" -- rules/0001.yml -- groups: diff --git a/cmd/pint/tests/0092_dir_symlink.txt b/cmd/pint/tests/0092_dir_symlink.txt index 7b5dbb7d..6499a5e6 100644 --- a/cmd/pint/tests/0092_dir_symlink.txt +++ b/cmd/pint/tests/0092_dir_symlink.txt @@ -11,6 +11,7 @@ cmp stderr stderr.txt level=INFO msg="Finding all rules to check" paths=["rules","linked","rules/src/rule.yaml"] level=DEBUG msg="File parsed" path=rules/src/rule.yaml rules=1 level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/src/rule.yaml record=down lines=4-5 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/src/rule.yaml rule=down diff --git a/cmd/pint/tests/0095_rulefmt_symlink.txt b/cmd/pint/tests/0095_rulefmt_symlink.txt index f5e52410..cee52f62 100644 --- a/cmd/pint/tests/0095_rulefmt_symlink.txt +++ b/cmd/pint/tests/0095_rulefmt_symlink.txt @@ -12,6 +12,7 @@ level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/relaxed/1.yml rules=1 level=DEBUG msg="File parsed" path=rules/strict/symlink.yml rules=1 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/relaxed/1.yml record=foo lines=1-2 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/relaxed/1.yml rule=foo diff --git a/cmd/pint/tests/0099_symlink_outside_glob.txt b/cmd/pint/tests/0099_symlink_outside_glob.txt index a48dfdcb..d8733700 100644 --- a/cmd/pint/tests/0099_symlink_outside_glob.txt +++ b/cmd/pint/tests/0099_symlink_outside_glob.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules/relaxed"] level=DEBUG msg="File parsed" path=rules/relaxed/1.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/relaxed/1.yml record=foo lines=1-2 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/relaxed/1.yml rule=foo diff --git a/cmd/pint/tests/0103_file_disable.txt b/cmd/pint/tests/0103_file_disable.txt index d0b5ee18..3904923d 100644 --- a/cmd/pint/tests/0103_file_disable.txt +++ b/cmd/pint/tests/0103_file_disable.txt @@ -10,6 +10,7 @@ level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] level=DEBUG msg="Starting query workers" name=prom uri=http://127.0.0.1:7103 workers=16 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=1 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:test1 lines=9-10 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp","promql/vector_matching(prom)","labels/conflict(prom)","alerts/external_labels(prom)","alerts/absent(prom)"] path=rules/0001.yml rule=colo:test1 diff --git a/cmd/pint/tests/0108_rule_duplicate.txt b/cmd/pint/tests/0108_rule_duplicate.txt index 480d6997..2590713a 100644 --- a/cmd/pint/tests/0108_rule_duplicate.txt +++ b/cmd/pint/tests/0108_rule_duplicate.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=8 workers=10 online=true level=ERROR msg="Query returned an error" err="failed to query Prometheus config: Get \"http://127.0.0.1:7108/api/v1/status/config\": dial tcp 127.0.0.1:7108: connect: connection refused" uri=http://127.0.0.1:7108 query=/api/v1/status/config level=ERROR msg="Query returned an error" err="failed to query Prometheus config: Get \"http://127.0.0.1:7108/api/v1/status/config\": dial tcp 127.0.0.1:7108: connect: connection refused" uri=http://127.0.0.1:7108 query=/api/v1/status/config level=ERROR msg="Query returned an error" err="failed to query Prometheus config: Get \"http://127.0.0.1:7108/api/v1/status/config\": dial tcp 127.0.0.1:7108: connect: connection refused" uri=http://127.0.0.1:7108 query=/api/v1/status/config diff --git a/cmd/pint/tests/0109_rule_duplicate_multiple_proms_include.txt b/cmd/pint/tests/0109_rule_duplicate_multiple_proms_include.txt index 887eca75..2d2bd8a5 100644 --- a/cmd/pint/tests/0109_rule_duplicate_multiple_proms_include.txt +++ b/cmd/pint/tests/0109_rule_duplicate_multiple_proms_include.txt @@ -7,6 +7,7 @@ level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=["^rules/0001.yml$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=["^rules/0002.yml$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=8 workers=10 online=true -- rules/0001.yml -- - record: "colo:duplicate" expr: sum(foo) without(job) diff --git a/cmd/pint/tests/0110_rule_duplicate_multiple_proms_exclude.txt b/cmd/pint/tests/0110_rule_duplicate_multiple_proms_exclude.txt index 037edbb2..98e90c2c 100644 --- a/cmd/pint/tests/0110_rule_duplicate_multiple_proms_exclude.txt +++ b/cmd/pint/tests/0110_rule_duplicate_multiple_proms_exclude.txt @@ -7,6 +7,7 @@ level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=[] exclude=["^rules/0002.yml$"] level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=[] exclude=["^rules/0001.yml$"] +level=INFO msg="Checking Prometheus rules" entries=8 workers=10 online=true -- rules/0001.yml -- - record: "colo:duplicate" expr: sum(foo) without(job) diff --git a/cmd/pint/tests/0111_snooze.txt b/cmd/pint/tests/0111_snooze.txt index f3267764..c835203b 100644 --- a/cmd/pint/tests/0111_snooze.txt +++ b/cmd/pint/tests/0111_snooze.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true 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 state=noop level=DEBUG msg="Check snoozed by comment" check=promql/aggregate(job:true) match=promql/aggregate until="2099-11-28T10:24:18Z" diff --git a/cmd/pint/tests/0112_expired_snooze.txt b/cmd/pint/tests/0112_expired_snooze.txt index 52f852e0..67ba8ab7 100644 --- a/cmd/pint/tests/0112_expired_snooze.txt +++ b/cmd/pint/tests/0112_expired_snooze.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true 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 state=noop 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 diff --git a/cmd/pint/tests/0115_file_disable_tag.txt b/cmd/pint/tests/0115_file_disable_tag.txt index 800475eb..135e9f55 100644 --- a/cmd/pint/tests/0115_file_disable_tag.txt +++ b/cmd/pint/tests/0115_file_disable_tag.txt @@ -10,6 +10,7 @@ level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=["foo","bar"] include=[] exclude=[] level=DEBUG msg="Starting query workers" name=prom uri=http://127.0.0.1:7103 workers=16 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=1 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=colo:test1 lines=6-8 state=noop level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp","alerts/external_labels(prom)","promql/counter(prom)","alerts/absent(prom)"] path=rules/0001.yml rule=colo:test1 diff --git a/cmd/pint/tests/0116_file_snooze.txt b/cmd/pint/tests/0116_file_snooze.txt index ca718290..3e3c1be3 100644 --- a/cmd/pint/tests/0116_file_snooze.txt +++ b/cmd/pint/tests/0116_file_snooze.txt @@ -10,6 +10,7 @@ level=DEBUG msg="Check snoozed by comment" check=promql/aggregate(job:true) matc level=DEBUG msg="Check snoozed by comment" check=alerts/for match=alerts/for until="2099-11-28T10:24:18Z" level=DEBUG msg="File parsed" path=rules/0001.yml rules=2 level=DEBUG msg="Glob finder completed" count=2 +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true 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 state=noop 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 diff --git a/cmd/pint/tests/0121_rule_for.txt b/cmd/pint/tests/0121_rule_for.txt index 33cde564..d1356735 100644 --- a/cmd/pint/tests/0121_rule_for.txt +++ b/cmd/pint/tests/0121_rule_for.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=4 workers=10 online=true rules/0001.yml:6 Bug: This alert rule must have a `for` field with a minimum duration of 5m. (rule/for) 6 | for: 3m diff --git a/cmd/pint/tests/0122_lint_owner_allowed.txt b/cmd/pint/tests/0122_lint_owner_allowed.txt index 9951691a..571a9ead 100644 --- a/cmd/pint/tests/0122_lint_owner_allowed.txt +++ b/cmd/pint/tests/0122_lint_owner_allowed.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=5 workers=10 online=true rules/1.yml:4-5 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: No Owner 5 | expr: up > 0 diff --git a/cmd/pint/tests/0124_ci_base_branch_flag.txt b/cmd/pint/tests/0124_ci_base_branch_flag.txt index c64702e3..1387c0ee 100644 --- a/cmd/pint/tests/0124_ci_base_branch_flag.txt +++ b/cmd/pint/tests/0124_ci_base_branch_flag.txt @@ -22,6 +22,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=INFO msg="Problems found" Fatal=1 rules.yml:2 Fatal: Prometheus failed to parse the query with this PromQL error: unexpected identifier "bi". (promql/syntax) 2 | expr: sum(foo) bi(job) diff --git a/cmd/pint/tests/0125_lint_fail_on_warning.txt b/cmd/pint/tests/0125_lint_fail_on_warning.txt index bba2cbfe..efc7f73e 100644 --- a/cmd/pint/tests/0125_lint_fail_on_warning.txt +++ b/cmd/pint/tests/0125_lint_fail_on_warning.txt @@ -11,6 +11,7 @@ groups: -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/0001.yml:5 Warning: Alert query doesn't have any condition, it will always fire if the metric exists. (alerts/comparison) 5 | expr: up{job=~"xxx"} diff --git a/cmd/pint/tests/0126_lint_fail_on_invalid.txt b/cmd/pint/tests/0126_lint_fail_on_invalid.txt index eca135fb..f0a0da4c 100644 --- a/cmd/pint/tests/0126_lint_fail_on_invalid.txt +++ b/cmd/pint/tests/0126_lint_fail_on_invalid.txt @@ -7,5 +7,6 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=0 workers=10 online=true level=INFO msg="No rules found, skipping Prometheus discovery" level=ERROR msg="Fatal error" err="invalid --fail-on value: unknown severity: xxx" diff --git a/cmd/pint/tests/0127_lint_fail_on_fatal_but_got_warning.txt b/cmd/pint/tests/0127_lint_fail_on_fatal_but_got_warning.txt index be5b57ce..630b5cd4 100644 --- a/cmd/pint/tests/0127_lint_fail_on_fatal_but_got_warning.txt +++ b/cmd/pint/tests/0127_lint_fail_on_fatal_but_got_warning.txt @@ -11,5 +11,6 @@ groups: -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Problems found" Warning=1 level=INFO msg="1 problem(s) not visible because of --min-severity=bug flag" diff --git a/cmd/pint/tests/0128_lint_fail_on_warning_only.txt b/cmd/pint/tests/0128_lint_fail_on_warning_only.txt index e26106dd..50e8dd9a 100644 --- a/cmd/pint/tests/0128_lint_fail_on_warning_only.txt +++ b/cmd/pint/tests/0128_lint_fail_on_warning_only.txt @@ -11,6 +11,7 @@ groups: -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Problems found" Warning=1 level=INFO msg="1 problem(s) not visible because of --min-severity=bug flag" level=ERROR msg="Fatal error" err="found 1 problem(s) with severity Warning or higher" diff --git a/cmd/pint/tests/0136_annotation_regex_key.txt b/cmd/pint/tests/0136_annotation_regex_key.txt index c7d52db8..c9e49955 100644 --- a/cmd/pint/tests/0136_annotation_regex_key.txt +++ b/cmd/pint/tests/0136_annotation_regex_key.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true -- rules/0001.yml -- - alert: Instance Is Down 1 expr: up == 0 diff --git a/cmd/pint/tests/0137_annotation_regex_key_fail.txt b/cmd/pint/tests/0137_annotation_regex_key_fail.txt index 2a2e27c1..2259c56c 100644 --- a/cmd/pint/tests/0137_annotation_regex_key_fail.txt +++ b/cmd/pint/tests/0137_annotation_regex_key_fail.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/0001.yml:4 Bug: `annotation_.*` annotation value `foo` must match `^bar$`. (alerts/annotation) 4 | annotation_foo: foo diff --git a/cmd/pint/tests/0138_annoation_regex_key_required.txt b/cmd/pint/tests/0138_annoation_regex_key_required.txt index bfaddd99..27088c1e 100644 --- a/cmd/pint/tests/0138_annoation_regex_key_required.txt +++ b/cmd/pint/tests/0138_annoation_regex_key_required.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/0001.yml:1-2 Bug: `annotation_.*` annotation is required. (alerts/annotation) 1 | - alert: Instance Is Down 1 2 | expr: up == 0 diff --git a/cmd/pint/tests/0141_empty_keys.txt b/cmd/pint/tests/0141_empty_keys.txt index a395f2c0..bbf38dff 100644 --- a/cmd/pint/tests/0141_empty_keys.txt +++ b/cmd/pint/tests/0141_empty_keys.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules.yml"] +level=INFO msg="Checking Prometheus rules" entries=6 workers=10 online=true rules.yml:4 Fatal: This rule is not a valid Prometheus rule: `record value cannot be empty`. (yaml/parse) 4 | - record: diff --git a/cmd/pint/tests/0142_keep_firing_for.txt b/cmd/pint/tests/0142_keep_firing_for.txt index c09b5d77..a9d143ab 100644 --- a/cmd/pint/tests/0142_keep_firing_for.txt +++ b/cmd/pint/tests/0142_keep_firing_for.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true -- rules/0001.yml -- - alert: Instance Is Down 1 expr: up == 0 diff --git a/cmd/pint/tests/0143_keep_firing_for.txt b/cmd/pint/tests/0143_keep_firing_for.txt index 30f0a456..e8ab2572 100644 --- a/cmd/pint/tests/0143_keep_firing_for.txt +++ b/cmd/pint/tests/0143_keep_firing_for.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=4 workers=10 online=true rules/0001.yml:6 Bug: This alert rule must have a `keep_firing_for` field with a minimum duration of 5m. (rule/for) 6 | keep_firing_for: 3m diff --git a/cmd/pint/tests/0144_discovery_filepath.txt b/cmd/pint/tests/0144_discovery_filepath.txt index 48f0627c..860ddf5b 100644 --- a/cmd/pint/tests/0144_discovery_filepath.txt +++ b/cmd/pint/tests/0144_discovery_filepath.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Finding Prometheus servers using file paths" dir=servers match=^(?P\w+).ya?ml$ level=DEBUG msg="Path discovery match" match=^(?P\w+).ya?ml$ path=prom1.yaml level=DEBUG msg="Extracted regexp variables" regexp=^(?P\w+).ya?ml$ vars={"name":"prom1"} diff --git a/cmd/pint/tests/0145_discovery_filepath_dup.txt b/cmd/pint/tests/0145_discovery_filepath_dup.txt index 7db5db38..ec9da3d3 100644 --- a/cmd/pint/tests/0145_discovery_filepath_dup.txt +++ b/cmd/pint/tests/0145_discovery_filepath_dup.txt @@ -10,6 +10,7 @@ level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="Glob finder completed" count=1 level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=[] exclude=[] level=DEBUG msg="Starting query workers" name=prom2 uri=https://unique.example.com workers=16 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Finding Prometheus servers using file paths" dir=servers match=^(?P\w+).ya?ml$ level=DEBUG msg="Path discovery match" match=^(?P\w+).ya?ml$ path=prom1.yaml level=DEBUG msg="Extracted regexp variables" regexp=^(?P\w+).ya?ml$ vars={"name":"prom1"} diff --git a/cmd/pint/tests/0147_discovery_filepath_error.txt b/cmd/pint/tests/0147_discovery_filepath_error.txt index a12b0604..85b43bf2 100644 --- a/cmd/pint/tests/0147_discovery_filepath_error.txt +++ b/cmd/pint/tests/0147_discovery_filepath_error.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=INFO msg="Finding Prometheus servers using file paths" dir=notfound match=^(?P\w+).ya?ml$ level=ERROR msg="Fatal error" err="filepath discovery error: lstat notfound: no such file or directory" -- rules/0001.yml -- diff --git a/cmd/pint/tests/0148_discovery_prom_zero.txt b/cmd/pint/tests/0148_discovery_prom_zero.txt index 14c36eb2..2c1bf0bd 100644 --- a/cmd/pint/tests/0148_discovery_prom_zero.txt +++ b/cmd/pint/tests/0148_discovery_prom_zero.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7148 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7148 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7148 query=prometheus_ready diff --git a/cmd/pint/tests/0149_discovery_prom.txt b/cmd/pint/tests/0149_discovery_prom.txt index f6ca1ffc..a92f0843 100644 --- a/cmd/pint/tests/0149_discovery_prom.txt +++ b/cmd/pint/tests/0149_discovery_prom.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7149 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7149 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7149 query=prometheus_ready diff --git a/cmd/pint/tests/0150_discovery_prom_dup_tags.txt b/cmd/pint/tests/0150_discovery_prom_dup_tags.txt index c91b8a0b..ddf5abc1 100644 --- a/cmd/pint/tests/0150_discovery_prom_dup_tags.txt +++ b/cmd/pint/tests/0150_discovery_prom_dup_tags.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7150 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7150 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7150 query=prometheus_ready diff --git a/cmd/pint/tests/0151_discovery_prom_error.txt b/cmd/pint/tests/0151_discovery_prom_error.txt index bc245f64..1a0083d5 100644 --- a/cmd/pint/tests/0151_discovery_prom_error.txt +++ b/cmd/pint/tests/0151_discovery_prom_error.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7151 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7151 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7151 query=prometheus_ready diff --git a/cmd/pint/tests/0152_discovery_prom_dup_uptime.txt b/cmd/pint/tests/0152_discovery_prom_dup_uptime.txt index b5813fc2..0b612b73 100644 --- a/cmd/pint/tests/0152_discovery_prom_dup_uptime.txt +++ b/cmd/pint/tests/0152_discovery_prom_dup_uptime.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7152 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7152 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7152 query=prometheus_ready diff --git a/cmd/pint/tests/0155_discovery_prom_dup_include.txt b/cmd/pint/tests/0155_discovery_prom_dup_include.txt index ae787565..3f31be14 100644 --- a/cmd/pint/tests/0155_discovery_prom_dup_include.txt +++ b/cmd/pint/tests/0155_discovery_prom_dup_include.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7155 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7155 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7155 query=prometheus_ready diff --git a/cmd/pint/tests/0156_discovery_prom_dup_exclude.txt b/cmd/pint/tests/0156_discovery_prom_dup_exclude.txt index e21eeaee..c12cba33 100644 --- a/cmd/pint/tests/0156_discovery_prom_dup_exclude.txt +++ b/cmd/pint/tests/0156_discovery_prom_dup_exclude.txt @@ -11,6 +11,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl 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=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Starting query workers" name=discovery uri=http://127.0.0.1:7156 workers=1 level=INFO msg="Finding Prometheus servers using Prometheus API query" uri=http://127.0.0.1:7156 query=prometheus_ready level=DEBUG msg="Scheduling prometheus query" uri=http://127.0.0.1:7156 query=prometheus_ready diff --git a/cmd/pint/tests/0157_series_other_servers.txt b/cmd/pint/tests/0157_series_other_servers.txt index 26be826e..a0ca5d4b 100644 --- a/cmd/pint/tests/0157_series_other_servers.txt +++ b/cmd/pint/tests/0157_series_other_servers.txt @@ -17,6 +17,7 @@ level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=["^rules/1.yml$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=["^rules/2.yml$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom1 metric=up level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom1 metric=up rules/1.yml:5 Bug: `prom1` Prometheus server at http://127.0.0.1:7157 didn't have any series for `only_on_prom2` metric in the last 1w. (promql/series) diff --git a/cmd/pint/tests/0158_lint_teamcity.txt b/cmd/pint/tests/0158_lint_teamcity.txt index 11763c00..e0acfbef 100644 --- a/cmd/pint/tests/0158_lint_teamcity.txt +++ b/cmd/pint/tests/0158_lint_teamcity.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true ##teamcity[testSuiteStarted name='alerts/comparison'] ##teamcity[testSuiteStarted name='Warning'] ##teamcity[testStarted name='rules/0001.yml:5'] diff --git a/cmd/pint/tests/0159_ci_teamcity.txt b/cmd/pint/tests/0159_ci_teamcity.txt index 7287f06a..58000886 100644 --- a/cmd/pint/tests/0159_ci_teamcity.txt +++ b/cmd/pint/tests/0159_ci_teamcity.txt @@ -29,6 +29,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=INFO msg="Problems found" Fatal=1 Warning=1 ##teamcity[testSuiteStarted name='promql/syntax'] ##teamcity[testSuiteStarted name='Fatal'] diff --git a/cmd/pint/tests/0160_ci_comment_edit.txt b/cmd/pint/tests/0160_ci_comment_edit.txt index d5062806..04c3a850 100644 --- a/cmd/pint/tests/0160_ci_comment_edit.txt +++ b/cmd/pint/tests/0160_ci_comment_edit.txt @@ -38,10 +38,12 @@ cmp stderr ../stderrV2.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- stderrV2.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom metric=up level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up diff --git a/cmd/pint/tests/0161_ci_move_files.txt b/cmd/pint/tests/0161_ci_move_files.txt index 9d3785f5..3bd23d63 100644 --- a/cmd/pint/tests/0161_ci_move_files.txt +++ b/cmd/pint/tests/0161_ci_move_files.txt @@ -39,6 +39,7 @@ level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=["^prom1.yml$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=["^prom2.yml$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- stderrV2.txt -- prom2.yml:10 Bug: `prom2` Prometheus server at http://127.0.0.1:7161/2 didn't have any series for `up` metric in the last 1w. (promql/series) 10 | expr: up == 0 diff --git a/cmd/pint/tests/0165_pint_comment_error.txt b/cmd/pint/tests/0165_pint_comment_error.txt index 961e7fd8..f1b76c84 100644 --- a/cmd/pint/tests/0165_pint_comment_error.txt +++ b/cmd/pint/tests/0165_pint_comment_error.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true rules/1.yml:4 Warning: This comment is not a valid pint control comment: unexpected comment suffix: "this line" (pint/comment) 4 | # pint ignore/line this line diff --git a/cmd/pint/tests/0166_invalid_label.txt b/cmd/pint/tests/0166_invalid_label.txt index 6dae2a7a..66278b8f 100644 --- a/cmd/pint/tests/0166_invalid_label.txt +++ b/cmd/pint/tests/0166_invalid_label.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/1.yaml:7 Fatal: This rule is not a valid Prometheus rule: `invalid annotation name: {{ $value }}`. (yaml/parse) 7 | "{{ $value }}": "down" diff --git a/cmd/pint/tests/0167_rule_duplicate_symlink.txt b/cmd/pint/tests/0167_rule_duplicate_symlink.txt index 39f639a8..32723f04 100644 --- a/cmd/pint/tests/0167_rule_duplicate_symlink.txt +++ b/cmd/pint/tests/0167_rule_duplicate_symlink.txt @@ -30,6 +30,7 @@ level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=["^rules.yml$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2 uris=1 uptime=up tags=[] include=["^symlink.yml$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=6 workers=10 online=true -- stderrV2.txt -- -- src/v0.yml -- groups: diff --git a/cmd/pint/tests/0171_rule_duplicate_rename.txt b/cmd/pint/tests/0171_rule_duplicate_rename.txt index 38c28002..4570b91f 100644 --- a/cmd/pint/tests/0171_rule_duplicate_rename.txt +++ b/cmd/pint/tests/0171_rule_duplicate_rename.txt @@ -34,6 +34,7 @@ cmp stderr ../stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=["^.*.yaml$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom metric=up level=INFO msg="Problems found" Bug=1 diff --git a/cmd/pint/tests/0173_rule_duplicate_move.txt b/cmd/pint/tests/0173_rule_duplicate_move.txt index 169f3b29..667a3260 100644 --- a/cmd/pint/tests/0173_rule_duplicate_move.txt +++ b/cmd/pint/tests/0173_rule_duplicate_move.txt @@ -28,6 +28,7 @@ level=INFO msg="Finding all rules to check on current git branch" base=main level=INFO msg="Configured new Prometheus server" name=prom1 uris=1 uptime=up tags=[] include=["^rules/alert.*$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2a uris=1 uptime=up tags=[] include=["^rules/record.*$"] exclude=[] level=INFO msg="Configured new Prometheus server" name=prom2b uris=1 uptime=up tags=[] include=["^rules/record.*$"] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=7 workers=10 online=true -- src/v1/rules/alert1.yml -- groups: - name: g1 diff --git a/cmd/pint/tests/0175_strict_multi_doc.txt b/cmd/pint/tests/0175_strict_multi_doc.txt index 98daabbb..5a5d42f8 100644 --- a/cmd/pint/tests/0175_strict_multi_doc.txt +++ b/cmd/pint/tests/0175_strict_multi_doc.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=5 workers=10 online=true rules/strict.yml:7 Fatal: This rule is not a valid Prometheus rule: `multi-document YAML files are not allowed`. (yaml/parse) 7 | --- diff --git a/cmd/pint/tests/0176_comments.txt b/cmd/pint/tests/0176_comments.txt index 9e47dbab..8fba28d5 100644 --- a/cmd/pint/tests/0176_comments.txt +++ b/cmd/pint/tests/0176_comments.txt @@ -13,6 +13,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[] +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom metric=up rules/1.yml:15 Bug: `prom` Prometheus server at http://127.0.0.1:7176 didn't have any series for `up` metric in the last 1w. (promql/series) diff --git a/cmd/pint/tests/0177_rule_name.txt b/cmd/pint/tests/0177_rule_name.txt index 50a8b03e..b6da05c7 100644 --- a/cmd/pint/tests/0177_rule_name.txt +++ b/cmd/pint/tests/0177_rule_name.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/01.yml:4 Bug: alerting rule name must match `^rec:.+$`. (rule/name) 4 | - alert: foo diff --git a/cmd/pint/tests/0178_parser_include.txt b/cmd/pint/tests/0178_parser_include.txt index 45f2c3de..7659e540 100644 --- a/cmd/pint/tests/0178_parser_include.txt +++ b/cmd/pint/tests/0178_parser_include.txt @@ -8,7 +8,9 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File path is in the include list" path=rules/0001.yml include=["^rules/0001.yml$"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 +level=DEBUG msg="File path is not allowed" path=rules/0002.yml include=["^rules/0001.yml$"] exclude=["^.pint.hcl$"] level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=ok lines=1-2 state=noop 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=ok diff --git a/cmd/pint/tests/0179_parser_exclude.txt b/cmd/pint/tests/0179_parser_exclude.txt index 9e7e4376..9ad788ed 100644 --- a/cmd/pint/tests/0179_parser_exclude.txt +++ b/cmd/pint/tests/0179_parser_exclude.txt @@ -9,6 +9,7 @@ level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="File path is in the exclude list" path=rules/0002.yml exclude=["^rules/0002.yml$","^.pint.hcl$"] level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=ok lines=1-2 state=noop 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=ok diff --git a/cmd/pint/tests/0180_parser_exclude_md.txt b/cmd/pint/tests/0180_parser_exclude_md.txt index 29638a1f..c01bf4ea 100644 --- a/cmd/pint/tests/0180_parser_exclude_md.txt +++ b/cmd/pint/tests/0180_parser_exclude_md.txt @@ -9,6 +9,7 @@ level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=1 level=DEBUG msg="File path is in the exclude list" path=rules/README.md exclude=["^.*.md$","^.pint.hcl$"] level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yml record=ok lines=1-2 state=noop 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=ok diff --git a/cmd/pint/tests/0181_range_query_max.txt b/cmd/pint/tests/0181_range_query_max.txt index 1acd287b..491c7543 100644 --- a/cmd/pint/tests/0181_range_query_max.txt +++ b/cmd/pint/tests/0181_range_query_max.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/0001.yaml:2 Warning: `errors[1h1s]` selector is trying to query Prometheus for 1h1s worth of metrics, but 1h is the maximum allowed range query. (promql/range_query) 2 | expr: sum(rate(errors[1h1s])) > 0.5 diff --git a/cmd/pint/tests/0182_range_query_custom_severity.txt b/cmd/pint/tests/0182_range_query_custom_severity.txt index 9bc4c397..5b24364e 100644 --- a/cmd/pint/tests/0182_range_query_custom_severity.txt +++ b/cmd/pint/tests/0182_range_query_custom_severity.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/0001.yaml:2 Bug: `errors[1h1s]` selector is trying to query Prometheus for 1h1s worth of metrics, but 1h is the maximum allowed range query. (promql/range_query) 2 | expr: sum(rate(errors[1h1s])) > 0.5 diff --git a/cmd/pint/tests/0183_cli_enable.txt b/cmd/pint/tests/0183_cli_enable.txt index 58a1c1f3..d5af84cb 100644 --- a/cmd/pint/tests/0183_cli_enable.txt +++ b/cmd/pint/tests/0183_cli_enable.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yml rules=3 level=DEBUG msg="Glob finder completed" count=3 +level=INFO msg="Checking Prometheus rules" entries=3 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found alerting rule" path=rules/0001.yml alert=default-for lines=1-3 state=noop level=DEBUG msg="Configured checks for rule" enabled=[] path=rules/0001.yml rule=default-for diff --git a/cmd/pint/tests/0184_ci_file_ignore.txt b/cmd/pint/tests/0184_ci_file_ignore.txt index e3e796b1..3243d519 100644 --- a/cmd/pint/tests/0184_ci_file_ignore.txt +++ b/cmd/pint/tests/0184_ci_file_ignore.txt @@ -23,6 +23,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true -- src/rules.yml -- # pint ignore/file - record: rule1 diff --git a/cmd/pint/tests/0185_state_empty.txt b/cmd/pint/tests/0185_state_empty.txt index 96f3d093..f24a29b4 100644 --- a/cmd/pint/tests/0185_state_empty.txt +++ b/cmd/pint/tests/0185_state_empty.txt @@ -23,6 +23,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- src/rules.yml -- - record: rule1 expr: sum(foo) by(job) diff --git a/cmd/pint/tests/0186_ci_state_any.txt b/cmd/pint/tests/0186_ci_state_any.txt index 2cd3ee72..308e62b5 100644 --- a/cmd/pint/tests/0186_ci_state_any.txt +++ b/cmd/pint/tests/0186_ci_state_any.txt @@ -23,6 +23,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=INFO msg="Problems found" Bug=1 rules.yml:4 Bug: `job` label is required and should be preserved when aggregating `^.+$` rules, use `by(job, ...)`. (promql/aggregate) 4 | expr: sum(foo) diff --git a/cmd/pint/tests/0187_ci_noop_yaml_parse.txt b/cmd/pint/tests/0187_ci_noop_yaml_parse.txt index 756759f7..f1413410 100644 --- a/cmd/pint/tests/0187_ci_noop_yaml_parse.txt +++ b/cmd/pint/tests/0187_ci_noop_yaml_parse.txt @@ -24,6 +24,7 @@ cmp stderr ../stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main level=WARN msg="Failed to parse file content" err="error at line 1: top level field must be a groups key, got list" path=rules.yml lines=1-5 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true -- src/rules.yml -- - record: rule1 expr: sum(foo) by(job) diff --git a/cmd/pint/tests/0192_ci_broken_removed_rule.txt b/cmd/pint/tests/0192_ci_broken_removed_rule.txt index 67750588..7bb33ed2 100644 --- a/cmd/pint/tests/0192_ci_broken_removed_rule.txt +++ b/cmd/pint/tests/0192_ci_broken_removed_rule.txt @@ -22,6 +22,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- src/rules.yml -- groups: - name: foo diff --git a/cmd/pint/tests/0195_checkstyle_lint_no_dir.txt b/cmd/pint/tests/0195_checkstyle_lint_no_dir.txt index a683c520..13ec0505 100644 --- a/cmd/pint/tests/0195_checkstyle_lint_no_dir.txt +++ b/cmd/pint/tests/0195_checkstyle_lint_no_dir.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=ERROR msg="Fatal error" err="open x/y/z/checkstyle.xml: no such file or directory" -- rules/0001.yml -- groups: diff --git a/cmd/pint/tests/0197_checkstyle_ci_no_dir.txt b/cmd/pint/tests/0197_checkstyle_ci_no_dir.txt index 2a76370b..6a4cb02a 100644 --- a/cmd/pint/tests/0197_checkstyle_ci_no_dir.txt +++ b/cmd/pint/tests/0197_checkstyle_ci_no_dir.txt @@ -45,5 +45,6 @@ parser { -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=false level=INFO msg="Offline mode, skipping Prometheus discovery" level=ERROR msg="Fatal error" err="open x/y/z/checkstyle.xml: no such file or directory" diff --git a/cmd/pint/tests/0199_json_no_dir.txt b/cmd/pint/tests/0199_json_no_dir.txt index 4342e686..74cabd5a 100644 --- a/cmd/pint/tests/0199_json_no_dir.txt +++ b/cmd/pint/tests/0199_json_no_dir.txt @@ -4,6 +4,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true level=ERROR msg="Fatal error" err="open x/y/z/problems.json: no such file or directory" -- rules/0001.yml -- groups: diff --git a/cmd/pint/tests/0201_json_ci_no_dir.txt b/cmd/pint/tests/0201_json_ci_no_dir.txt index 2f9c3fae..171fcc95 100644 --- a/cmd/pint/tests/0201_json_ci_no_dir.txt +++ b/cmd/pint/tests/0201_json_ci_no_dir.txt @@ -22,6 +22,7 @@ cmp stderr ../stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check on current git branch" base=main +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=false level=INFO msg="Offline mode, skipping Prometheus discovery" level=ERROR msg="Fatal error" err="open x/y/z/report.json: no such file or directory" -- src/v1.yml -- diff --git a/cmd/pint/tests/0202_report_recording_rules.txt b/cmd/pint/tests/0202_report_recording_rules.txt index a59dd37d..375bc120 100644 --- a/cmd/pint/tests/0202_report_recording_rules.txt +++ b/cmd/pint/tests/0202_report_recording_rules.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true rules/1.yml:3-4 Bug: You cannot add any recording rules to this Prometheus server. (rule/report) 3 | - record: bar 4 | expr: sum(up) diff --git a/cmd/pint/tests/0203_parser_schema_prom_err.txt b/cmd/pint/tests/0203_parser_schema_prom_err.txt index 252ac48b..ce1ee4ab 100644 --- a/cmd/pint/tests/0203_parser_schema_prom_err.txt +++ b/cmd/pint/tests/0203_parser_schema_prom_err.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 3: partial_response_strategy is only valid when parser is configured to use the Thanos rule schema" path=rules/1.yml lines=1-9 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/1.yml:3 Fatal: partial_response_strategy is only valid when parser is configured to use the Thanos rule schema (yaml/parse) 3 | partial_response_strategy: warn diff --git a/cmd/pint/tests/0204_parser_schema_thanos_err.txt b/cmd/pint/tests/0204_parser_schema_thanos_err.txt index 7e72642e..5aa97264 100644 --- a/cmd/pint/tests/0204_parser_schema_thanos_err.txt +++ b/cmd/pint/tests/0204_parser_schema_thanos_err.txt @@ -6,6 +6,7 @@ cmp stderr stderr.txt level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=WARN msg="Failed to parse file content" err="error at line 3: invalid partial_response_strategy value: bob" path=rules/1.yml lines=1-9 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true rules/1.yml:3 Fatal: invalid partial_response_strategy value: bob (yaml/parse) 3 | partial_response_strategy: bob diff --git a/cmd/pint/tests/0205_parser_schema_thanos_ok.txt b/cmd/pint/tests/0205_parser_schema_thanos_ok.txt index 927db49b..6a4b8b5d 100644 --- a/cmd/pint/tests/0205_parser_schema_thanos_ok.txt +++ b/cmd/pint/tests/0205_parser_schema_thanos_ok.txt @@ -5,6 +5,7 @@ cmp stderr stderr.txt -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] +level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true -- rules/1.yml -- groups: - name: foo diff --git a/cmd/pint/tests/0207_locked_rule.txt b/cmd/pint/tests/0207_locked_rule.txt index 0bc587b2..9e8a2d0f 100644 --- a/cmd/pint/tests/0207_locked_rule.txt +++ b/cmd/pint/tests/0207_locked_rule.txt @@ -8,6 +8,7 @@ level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl level=INFO msg="Finding all rules to check" paths=["rules"] level=DEBUG msg="File parsed" path=rules/0001.yaml rules=1 level=DEBUG msg="Glob finder completed" count=1 +level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true level=DEBUG msg="Generated all Prometheus servers" count=0 level=DEBUG msg="Found recording rule" path=rules/0001.yaml record=colo_job:up:byinstance lines=6-7 state=noop 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.yaml rule=colo_job:up:byinstance diff --git a/cmd/pint/tests/0208_lint_full_path.txt b/cmd/pint/tests/0208_lint_full_path.txt new file mode 100644 index 00000000..378dcb77 --- /dev/null +++ b/cmd/pint/tests/0208_lint_full_path.txt @@ -0,0 +1,33 @@ +exec pint -l debug --no-color lint $WORK/rules +! stdout . +stderr 'level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true' +! stderr 'level=INFO msg="No rules found, skipping Prometheus discovery"' + +exec pint -l debug --no-color lint rules +! stdout . +stderr 'level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true' +! stderr 'level=INFO msg="No rules found, skipping Prometheus discovery"' + +exec pint -l debug --no-color lint ../*0208*/rules +! stdout . +stderr 'level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true' +! stderr 'level=INFO msg="No rules found, skipping Prometheus discovery"' + +-- rules/0001.yml -- +groups: +- name: test1 + rules: + - record: "colo:test1" + expr: sum(foo) without(job) + +-- rules/0002.yml -- +groups: +- name: test2 + rules: + - record: "colo:test2" + expr: sum(foo) without(job) + +-- .pint.hcl -- +parser { + include = ["(.*/)?rules/.*"] +} diff --git a/docs/configuration.md b/docs/configuration.md index d3347954..e78b6b3b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -81,11 +81,11 @@ parser { in [Thanos Rule](https://thanos.io/tip/components/rule.md/) docs, which currently allows for setting an extra key on the rule group object - `partial_response_strategy`. Default value is `prometheus`. -- `include` - list of file patterns to check when running checks. Only files +- `include` - list of regexp patterns to check when running checks. Only files matching those regexp rules will be checked, other modified files will be ignored. -- `exclude` - list of file patterns to ignore when running checks. +- `exclude` - list of regexp patterns to ignore when running checks. This option takes precedence over `include`, so if a file path matches both - `include` & `exclude` patterns, it will be excluded. + `include` & `exclude` regexp patterns, it will be excluded. - `relaxed` - by default, pint will parse all files in strict mode, where all rule files must have the exact syntax Prometheus or Thanos expects: @@ -118,9 +118,33 @@ parser { you can set this option to allow fuzzy parsing, which will try to find rule definitions anywhere in the file, without requiring `groups -> rules -> rule` structure to be present. - This option takes a list of file patterns, all files matching those regexp rules + This option takes a list of regexp patterns, all files matching those regexp rules will be parsed in relaxed mode. +**NOTE**: remember that all options that accept regexp patterns (shown as `"(.*)"` in syntax docs) are **anchored**. +If you do set any patterns in the `parser` section then they must match the way you run pint. +For example if you have a git repository with a `rules` directory containing Prometheus rules then +you might set `include = ["rules/.*"]` in the config. Which internally will be parsed as `$rules/.*$` regexp pattern. +This means that if you then pass absolute paths to pint commands (`pint lint /my/repo/rules`) it won't match that regexp. +If you do want to use pint with both relative and absolute paths make sure your regexp patterns allow for it, example: + +```js +parser { + include = [ "(.*/)?rules/.*" ] +} +``` + +Or explicitly set both relative and absolute path: + +```js +parser { + include = [ + "rules/.*", + "/my/repo/rules/.*", + ] +} +``` + ## Owners When `pint ci` or `pint lint` is run with `--require-owner` flag it will require @@ -414,7 +438,7 @@ instances is needed. This can be configured using `discovery` config blocks. ### File path discovery File path discovery allows to generate Prometheus server definitions used by pint -based on path patterns on disk. +based on path regexp patterns on disk. Syntax: ```js @@ -591,7 +615,7 @@ rule { - `locked` - if set to `true` this rule will be locked, which means that it cannot be disabled using `# pint disable ...` or `# pint snooze ...` comments. -- `match:path` - only files matching this pattern will be checked by this rule. +- `match:path` - only files matching this regexp pattern will be checked by this rule. - `match:state` - only match rules based on their state. Default value for `state` depends on the pint command that is being run, for `pint ci` the default value is `["added", "modified", "renamed"]`, for any other command the default value is `["any"]`. @@ -603,14 +627,14 @@ rule { - `removed` - a rule is being removed in a git commit, a rule can only be in this state when running `pint ci` on a pull request. - `unmodified` - a rule is not being modified in a git commit when running `pint ci` or other pint command was run that doesn't try to detect which rules were modified. - `match:name` - only rules with names (`record` for recording rules and `alert` for alerting - rules) matching this pattern will be checked rule. + rules) matching this regexp pattern will be checked rule. - `match:kind` - optional rule type filter, only rule of this type will be checked. - `match:command` - optional command type filter, this allows to include or ignore rules based on the command pint is run with `pint ci`, `pint lint` or `pint watch`. - `match:annotation` - optional annotation filter, only alert rules with at least one - annotation matching this pattern will be checked by this rule. + annotation matching this regexp pattern will be checked by this rule. - `match:label` - optional annotation filter, only rules with at least one label - matching this pattern will be checked by this rule. For recording rules only static + matching this regexp pattern will be checked by this rule. For recording rules only static labels set on the recording rule are considered. - `match:for` - optional alerting rule `for` filter. If set, only alerting rules with the `for` field present and matching the provided value will be checked by this rule. Recording rules diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 204b912e..fd0b90a3 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -65,8 +65,8 @@ const ( ) type Path struct { - Name string // file path, it can be symlink - SymlinkTarget string // symlink target, or the same as name if not a symlink + Name string // File path, it can be symlink. + SymlinkTarget string // Symlink target, or the same as name if not a symlink. } func (p Path) String() string { diff --git a/internal/git/filter.go b/internal/git/filter.go index 9dad8cb6..620a1c80 100644 --- a/internal/git/filter.go +++ b/internal/git/filter.go @@ -19,26 +19,40 @@ type PathFilter struct { relaxed []*regexp.Regexp } -func (pf PathFilter) IsPathAllowed(path string) bool { +func (pf PathFilter) IsPathAllowed(path string) (ok bool) { if len(pf.include) == 0 && len(pf.exclude) == 0 { return true } for _, pattern := range pf.exclude { if pattern.MatchString(path) { - slog.Debug("File path is in the exclude list", slog.String("path", path), slog.Any("exclude", pf.exclude)) + slog.Debug("File path is in the exclude list", + slog.String("path", path), + slog.Any("exclude", pf.exclude), + ) return false } } for _, pattern := range pf.include { if pattern.MatchString(path) { - slog.Debug("File path is in the include list", slog.String("path", path), slog.Any("include", pf.include)) + slog.Debug("File path is in the include list", + slog.String("path", path), + slog.Any("include", pf.include), + ) return true } } - return len(pf.include) == 0 + ok = len(pf.include) == 0 + if !ok { + slog.Debug("File path is not allowed", + slog.String("path", path), + slog.Any("include", pf.include), + slog.Any("exclude", pf.exclude), + ) + } + return ok } func (pf PathFilter) IsRelaxed(path string) bool {