Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat some errors #1247

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cmd/pint/tests/0054_watch_metrics_prometheus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmd/pint/tests/0108_rule_duplicate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cmd/pint/tests/0115_file_disable_tag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/checks/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/checks/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading