rule: PromQL annotations counted as store warnings when using the gRPC Query API (--query.config-file)
Thanos, Prometheus and Golang version used:
Thanos v0.42.4, Prometheus 3.11.3. Still present on main — pkg/query/remote_engine.go:380.
Object Storage Provider: AWS S3
What happened:
Moving Thanos Ruler from the HTTP Query API (--query) to the gRPC Query API
(--query.config-file with grpc_config.endpoint_addresses), with no other change, made
thanos_rule_evaluation_with_warnings_total{strategy="abort"} increment continuously and
the ruler log a level=warn line per affected evaluation.
None of them are store warnings. They are PromQL info annotations, mostly
PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket from rate()/increase() over gauges.
filterOutPromQLWarnings is supposed to drop exactly these, and does on the HTTP path.
Since that counter is what the evaluation-warning alert in docs/components/rule.md keys
off (> 0), such an alert fires permanently and can no longer indicate a real
partial-response condition.
What you expected to happen:
PromQL info/warning annotations are filtered out of the store-warning set on the gRPC path
too, so they neither increment thanos_rule_evaluation_with_warnings_total nor get logged
as store warnings.
How to reproduce it (as minimally and precisely as possible):
- Run Thanos Query and Thanos Ruler.
- Point the ruler at Query over gRPC —
--query.config-filecontaininggrpc_config: {endpoint_addresses: [...]}, and no--query. - Give it a rule yielding a PromQL info annotation, e.g.
rate(some_gauge[5m]) > 0wheresome_gaugeis a gauge with live series. thanos_rule_evaluation_with_warnings_totalincrements on every evaluation. Point the same ruler back at--queryand it stops.
Root cause:
pkg/query/remote_engine.go:380 prefixes every annotation from the remote engine:
warnings.Add(errors.Errorf("remote query warning (%s): %s", r.remoteAddr, warn))cmd/thanos/rule.go:1154 then classifies it with extannotations.IsPromQLAnnotation,
which is a prefix match on PromQL info: / PromQL warning: . The prepended wrapper
defeats it, so the annotation survives the filter, increments ruleEvalWarnings and is
logged as a store warning (rule.go:1041-1042 at v0.42.4). The HTTP path never goes
through remote_engine.go, which is why it is unaffected.
Anything else we need to know:
Looks like a regression of #7354: its fix (#7592, 2024-08-07) added
filterOutPromQLWarnings in cmd/thanos/rule.go only, while the wrapping in
remote_engine.go had landed earlier in #7286 (2024-04-18), so the gRPC path was never
covered.
Not a duplicate of #8229 — there the annotations are recognised and filtered (singular
warning= logged from inside filterOutPromQLWarnings, counter untouched), so that issue
is purely about log verbosity. #8873 lowers info annotations to debug but keys off the same
prefix check, so it would not fix the gRPC path either.
Suggested fix, either of:
- have
remote_engine.gopass PromQL annotations through unwrapped, or append the remote address as a suffix rather than a prefix; or - have
filterOutPromQLWarningsstrip theremote query warning (...):wrapper before the prefix check.
The first seems better, since any other prefix-based inspection of annotations downstream has the same latent problem. Happy to send a PR for whichever shape maintainers prefer.
Source: thanos-io/thanos