Skip to content

api: add infos field to query API response for Prometheus compatibility#8748

Open
abhay1999 wants to merge 1 commit intothanos-io:mainfrom
abhay1999:add-infos-field-query-api
Open

api: add infos field to query API response for Prometheus compatibility#8748
abhay1999 wants to merge 1 commit intothanos-io:mainfrom
abhay1999:add-infos-field-query-api

Conversation

@abhay1999
Copy link
Copy Markdown

@abhay1999 abhay1999 commented Apr 3, 2026

What does this PR do?

Prometheus added a separate infos field to the query API response in prometheus/prometheus#14327 to distinguish informational PromQL annotations (like histogram monotonicity corrections) from actionable warnings. Without this field, Thanos returns all PromQL infos mixed into warnings, which breaks clients that depend on Prometheus API compatibility.

This PR adds the infos field to Thanos's query API response and separates PromQL info annotations from warnings at the response layer.

Closes #7597

Changes

  • pkg/api/api.go: added Infos []string field to the response struct; updated Respond() to route PromQL info annotations to infos instead of warnings
  • pkg/extannotations/annotations.go: added IsPromQLInfo() helper (string-prefix based, matching the existing IsPromQLAnnotation approach, since gRPC serialization strips error type info)
  • pkg/api/api_test.go: added TestRespondInfosAndWarnings to verify the routing logic

Example response

{
  "status": "success",
  "data": { ... },
  "warnings": ["PromQL warning: mixed floats and histograms for ..."],
  "infos": ["PromQL info: input to histogram_quantile needed to be fixed for monotonicity ..."]
}

Checklist

  • I added unit tests for the new behavior
  • DCO sign-off included in commit
  • No existing tests broken by this change (pre-existing TestQueryEndpoints failure also reproduces on main without this PR)

Signed-off-by: Abhay Chaurasiya abhaychaurasiya19@gmail.com

Prometheus added a separate `infos` field to the query API response in
prometheus/prometheus#14327 to distinguish informational annotations (e.g.
histogram monotonicity fixes) from actionable warnings. Thanos needs the
same field to maintain Prometheus API compatibility.

PromQL info annotations wrap `annotations.PromQLInfo` and are detected
via a string prefix check (rather than errors.Is) because errors
serialized over gRPC lose their type information.

Signed-off-by: Abhay Chaurasiya <abhaychaurasiya19@gmail.com>
@abhay1999 abhay1999 force-pushed the add-infos-field-query-api branch from db8df7d to cd82d28 Compare April 3, 2026 04:18
@abhay1999
Copy link
Copy Markdown
Author

The Documentation check failure is unrelated to this PR. It's caused by 4 broken external links in pre-existing docs:

  • docs/components/store.md:646db.cs.cmu.edu DNS timeout
  • docs/getting-started.md:172 — SSL cert mismatch on infracloud.io
  • docs/sharding.md:21 — Grafana docs URL returning 404
  • docs/proposals-done/201909-thanos-sharding.md:89 — another Grafana URL returning 404

None of these files were modified in this PR. The same failure reproduces on main without any of these changes.

@abhay1999
Copy link
Copy Markdown
Author

The Thanos end-to-end tests (8, 4) failure is also unrelated to this PR. It's a timeout in TestReceive (test/e2e/receive_test.go:955) — WaitSumMetricsWithOptions exceeded the 600s limit waiting for metrics. This is a flaky infrastructure/timing issue in the Receive e2e suite. This PR only modifies pkg/api/api.go, pkg/extannotations/annotations.go, and pkg/api/api_test.go — none of which touch the Receive component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to the Info field in the body of query API responses

1 participant