diff --git a/cmd/pint/tests/0054_watch_metrics_prometheus.txt b/cmd/pint/tests/0054_watch_metrics_prometheus.txt index c486437b..6635bb03 100644 --- a/cmd/pint/tests/0054_watch_metrics_prometheus.txt +++ b/cmd/pint/tests/0054_watch_metrics_prometheus.txt @@ -90,19 +90,19 @@ pint_last_run_duration_seconds pint_last_run_time_seconds # HELP pint_problem Prometheus rule problem reported by pint # TYPE pint_problem gauge -pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run \"promql/counter\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/counter",severity="bug"} -pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run \"promql/range_query\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/range_query",severity="bug"} -pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run \"promql/rate\" checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="promql/rate",severity="bug"} -pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run \"promql/rate\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/rate",severity="bug"} -pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run \"promql/series\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/series",severity="bug"} +pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run `promql/counter` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/counter",severity="bug"} +pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run `promql/range_query` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/range_query",severity="bug"} +pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run `promql/rate` checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="promql/rate",severity="bug"} +pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run `promql/rate` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/rate",severity="bug"} +pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="Couldn't run `promql/series` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/series",severity="bug"} pint_problem{filename="rules/1.yml",kind="recording",name="aggregate",owner="",problem="`prom1` Prometheus server at http://127.0.0.1:7054 failed with: `bad_data: bogus query`.",reporter="promql/series",severity="bug"} pint_problem{filename="rules/1.yml",kind="recording",name="broken",owner="",problem="Prometheus failed to parse the query with this PromQL error: no arguments for aggregate expression provided.",reporter="promql/syntax",severity="fatal"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"alerts/external_labels\" checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="alerts/external_labels",severity="bug"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"alerts/external_labels\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="alerts/external_labels",severity="bug"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"promql/range_query\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/range_query",severity="bug"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"promql/rate\" checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="promql/rate",severity="bug"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"promql/rate\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/rate",severity="bug"} -pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run \"promql/series\" checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/series",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `alerts/external_labels` checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="alerts/external_labels",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `alerts/external_labels` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="alerts/external_labels",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `promql/range_query` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/range_query",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `promql/rate` checks due to `prom1` Prometheus server at http://127.0.0.1:7054 connection error: `server_error: 500 Internal Server Error`.",reporter="promql/rate",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `promql/rate` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/rate",severity="bug"} +pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="Couldn't run `promql/series` checks due to `prom2` Prometheus server at http://127.0.0.1:1054 connection error: `connection refused`.",reporter="promql/series",severity="bug"} pint_problem{filename="rules/2.yml",kind="alerting",name="comparison",owner="bob and alice",problem="`prom1` Prometheus server at http://127.0.0.1:7054 failed with: `bad_data: bogus query`.",reporter="promql/series",severity="bug"} # HELP pint_problems Total number of problems reported by pint # TYPE pint_problems gauge diff --git a/cmd/pint/tests/0108_rule_duplicate.txt b/cmd/pint/tests/0108_rule_duplicate.txt index 2590713a..f5b033b8 100644 --- a/cmd/pint/tests/0108_rule_duplicate.txt +++ b/cmd/pint/tests/0108_rule_duplicate.txt @@ -16,7 +16,7 @@ rules/0001.yml:1-2 Bug: Duplicated rule, identical rule found at rules/0002.yml: 1 | - record: "colo:duplicate" 2 | expr: sum(foo) without(job) -rules/0001.yml:7-8 Bug: Couldn't run "labels/conflict" checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) +rules/0001.yml:7-8 Bug: Couldn't run `labels/conflict` checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) 7 | labels: 8 | file: a @@ -26,19 +26,19 @@ rules/0001.yml:9-12 Bug: Duplicated rule, identical rule found at rules/0002.yml 11 | labels: 12 | same: yes -rules/0001.yml:11-12 Bug: Couldn't run "labels/conflict" checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) +rules/0001.yml:11-12 Bug: Couldn't run `labels/conflict` checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) 11 | labels: 12 | same: yes -rules/0002.yml:5-6 Bug: Couldn't run "labels/conflict" checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) +rules/0002.yml:5-6 Bug: Couldn't run `labels/conflict` checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) 5 | labels: 6 | empty: nope -rules/0002.yml:9-10 Bug: Couldn't run "labels/conflict" checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) +rules/0002.yml:9-10 Bug: Couldn't run `labels/conflict` checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) 9 | labels: 10 | file: b -rules/0002.yml:13-14 Bug: Couldn't run "labels/conflict" checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) +rules/0002.yml:13-14 Bug: Couldn't run `labels/conflict` checks due to `prom` Prometheus server at http://127.0.0.1:7108 connection error: `connection refused`. (labels/conflict) 13 | labels: 14 | same: yes diff --git a/cmd/pint/tests/0115_file_disable_tag.txt b/cmd/pint/tests/0115_file_disable_tag.txt index 135e9f55..bdeb3a76 100644 --- a/cmd/pint/tests/0115_file_disable_tag.txt +++ b/cmd/pint/tests/0115_file_disable_tag.txt @@ -17,7 +17,7 @@ level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo level=DEBUG msg="Scheduling Prometheus metrics metadata query" uri=http://127.0.0.1:7103 metric=foo level=DEBUG msg="Getting prometheus metrics metadata" uri=http://127.0.0.1:7103 metric=foo level=ERROR msg="Query returned an error" err="failed to query Prometheus metrics metadata: Get \"http://127.0.0.1:7103/api/v1/metadata?metric=foo\": dial tcp 127.0.0.1:7103: connect: connection refused" uri=http://127.0.0.1:7103 query=foo -rules/0001.yml:8 Warning: Couldn't run "promql/counter" checks due to `prom` Prometheus server at http://127.0.0.1:7103 connection error: `connection refused`. (promql/counter) +rules/0001.yml:8 Warning: Couldn't run `promql/counter` checks due to `prom` Prometheus server at http://127.0.0.1:7103 connection error: `connection refused`. (promql/counter) 8 | expr: sum(foo) without(job) level=INFO msg="Problems found" Warning=1 diff --git a/internal/checks/base.go b/internal/checks/base.go index da2c7591..5ecd9fee 100644 --- a/internal/checks/base.go +++ b/internal/checks/base.go @@ -149,13 +149,13 @@ func textAndSeverityFromError(err error, reporter, prom string, s Severity) (tex switch { case promapi.IsUnsupportedError(err): - text = fmt.Sprintf("Couldn't run %q checks on %s because it's %s.", reporter, promDesc, err) + text = fmt.Sprintf("Couldn't run `%s` checks on %s because it's %s.", reporter, promDesc, err) severity = Warning case promapi.IsQueryTooExpensive(err): - text = fmt.Sprintf("Couldn't run %q checks on %s because some queries are too expensive: `%s`.", reporter, promDesc, err) + text = fmt.Sprintf("Couldn't run `%s` checks on %s because some queries are too expensive: `%s`.", reporter, promDesc, err) severity = Warning case promapi.IsUnavailableError(err): - text = fmt.Sprintf("Couldn't run %q checks due to %s connection error: `%s`.", reporter, promDesc, err) + text = fmt.Sprintf("Couldn't run `%s` checks due to %s connection error: `%s`.", reporter, promDesc, err) severity = Warning if perrOk && perr.IsStrict() { severity = Bug diff --git a/internal/checks/base_test.go b/internal/checks/base_test.go index 20d4c37c..c54da4b0 100644 --- a/internal/checks/base_test.go +++ b/internal/checks/base_test.go @@ -590,13 +590,13 @@ func checkErrorBadData(name, uri, err string) string { } func checkErrorUnableToRun(c, name, uri, err string) string { - return fmt.Sprintf("Couldn't run %q checks due to `%s` Prometheus server at %s connection error: `%s`.", c, name, uri, err) + return fmt.Sprintf("Couldn't run `%s` checks due to `%s` Prometheus server at %s connection error: `%s`.", c, name, uri, err) } func checkErrorTooExpensiveToRun(c, name, uri, err string) string { - return fmt.Sprintf("Couldn't run %q checks on `%s` Prometheus server at %s because some queries are too expensive: `%s`.", c, name, uri, err) + return fmt.Sprintf("Couldn't run `%s` checks on `%s` Prometheus server at %s because some queries are too expensive: `%s`.", c, name, uri, err) } func checkUnsupported(c, name, uri, path string) string { - return fmt.Sprintf("Couldn't run %q checks on `%s` Prometheus server at %s because it's unsupported: this server doesn't seem to support `%s` API endpoint.", c, name, uri, path) + return fmt.Sprintf("Couldn't run `%s` checks on `%s` Prometheus server at %s because it's unsupported: this server doesn't seem to support `%s` API endpoint.", c, name, uri, path) }