Unify panel queries behind a single Prometheus-compatible datasource - #37
Open
sudosalim wants to merge 23 commits into
Open
Unify panel queries behind a single Prometheus-compatible datasource#37sudosalim wants to merge 23 commits into
sudosalim wants to merge 23 commits into
Conversation
m-tarhon
reviewed
Jun 4, 2026
m-tarhon
reviewed
Jun 4, 2026
sudosalim
force-pushed
the
datasource_gateway_proxy
branch
from
July 17, 2026 18:06
15ed5b9 to
570194c
Compare
Co-authored-by: <[email protected]>
Co-authored-by: <[email protected]>
Use prometheus query engine to run promql functions, only selectors generate slq++
sudosalim
force-pushed
the
datasource_gateway_proxy
branch
from
July 29, 2026 15:02
43ea877 to
e9d5ad0
Compare
sudosalim
marked this pull request as ready for review
August 6, 2026 17:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The plugin previously spoke to three datasources (Prometheus, a forked couchbase-datasource, and a ProxyPrometheus reverse proxy for snapshot comparison), with panel-building code branching per datasource and a
PromQL→SQL++ translator living inside the plugin backend. This collapses all of that into one datasource served by a standalone sidecar: the frontend always speaks PromQL, and the gateway decides where the data actually comes from.
The plugin backend no longer participates in querying at all, it manages settings, snapshot metadata, and datasource reconciliation.
New service:
datasource-gateway/A standalone Go service exposing a strict superset of the Prometheus HTTP API. Per query it routes by
snapshot:
rate/irate/increaseand every other construct match a passthrough by construction.job=~"a|b"): fans out per snapshot, queries each over its own window, and shifts timestamps to a sharedt=0axis so runs of different lengths can be overlaid.Because it's API-compatible, a deployment that needs neither Couchbase nor overlap can point straight at Prometheus and skip the gateway entirely.
Routing is driven by the snapshot's metadata document:
ts_startts_end"now"(or absent) marks a still-running snapshot, whose window ends at the current time and is re-resolved rather than cached.store"couchbase"routes through the SQL++ path; anything else, including absent, serves from Prometheus.Metadata is resolved once per snapshot and cached (with TTL), with concurrent lookups for the same snapshot sharing a single fetch.
Plugin and frontend
DataSourceToggleUI are gone, as isutils.cbquery.datasourceCapabilitiesservice reads/config/datasourcesand gates gateway-only affordances (currently the overlap toggle), degrading closed if the endpoint is unavailable.gatewayblock in app settings (enable / URL / overlap), configurable from the Configuration page or provisioning.prometheusUID and deletes any pre-existingcbdatasource, so existing deployments clean themselves up on the first reconcile pass.Configuration and deployment
The gateway is configured by layering, in increasing precedence: built-in defaults →
configs/datasource-gateway/config.yaml→DSG_*environment variables →section.field=valuearguments. Secrets should go through the environment; an argument would be visible viaps/docker inspect.The gateway is the generalisation of the https://github.com/m-tarhon/SyncedApp implementation.