tools: Add 'thanos tools' 'query range' and 'query instant' subcommands for running PromQL queries over Thanos gRPC API #8501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add commands
thanos tools query rangeandthanos tools query instantthat use the Thanos gRPC API to execute PromQL on a Thanos Query endpoint.This works like 'promtool query' for the Thanos gRPC API instead of the Prometheus HTTP API.
Using the Thanos gRPC API improves performance and lowers memory use by using protobuf instead of text json serialization. It also streams large result sets to the client, so the whole serialised result does not have to be accumulated in memory before any of it can be sent; this lowers latency and peak memory use.
Results cannot be fully streamed, because the Thanos executor still accumulates them into a promql.Result before sending any. But it helps reduce the memory overhead and latency of building the whole serialised response in memory while still holding the result data in memory. This lowers peak Query memory, and latency to first response.
Sending queries to Thanos Query Frontend is not currently supported, because Frontend only exposes the Prometheus HTTP API (and only uses the Prometheus HTTP API to talk to its downstreams).
Changes
querysubcommand group tothanos toolsquery rangeandquery instantsubcommands that use the thanos gRPC API to execute PromQL queries against a Thanos Query gRPC API endpointDetails
This is a WIP, with the following improvements still required:
Needs formatting options like promtoolExample use:
It can output results in
Unlike promtool, it emits stats and warnings too. These are exposed as
# commentsin the promql-format stream.Verification
This is still WIP and needs test cover added but manual testing is promising