You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds the missing piece of the exemplars MVP from perses/perses#3445: an optional enableExemplars toggle on the PrometheusTimeSeriesQuery spec, rendered as an Auto / On / Off button group in the query editor (same pattern as the existing instant toggle).
Semantics:
Auto (field unset): follow the exemplars.enable setting of the selected datasource — the behavior introduced with the MVP.
On: fetch exemplars for this query, even when the rest of the panel would not show them otherwise (still gated by the datasource toggle).
Off: skip the exemplars request for this query, even when the datasource has exemplars enabled.
A per-query On cannot override a datasource-level off: the effective flag is datasource.exemplars.enable === true && (spec.enableExemplars ?? true) && !isInstant — exemplars stay a datasource opt-in feature, and they are only fetched for range queries (the exemplars API is range-based).
Editor UX:
The button group sits next to the Range/Instant/Auto query-type group.
It is disabled when exemplars are disabled on the selected datasource (helper text: "Exemplars (disabled on the datasource)") or when the query is instant ("not available for instant queries"), with the state-aware message color so a misconfiguration is visible at a glance.
Also included:
enableExemplars?: bool in the plugin CUE schema.
EnableExemplars(bool) option on the Go SDK query builder (mirroring Instant).
Screenshots
Query editor with the Exemplars Auto/On/Off toggle:
Full panel editor context:
Testing
Unit tests for getTimeSeriesData: enableExemplars: false suppresses the exemplar request even when the datasource enables them; enableExemplars: true does not bypass a datasource-level off; instant queries never fetch exemplars (pre-existing behavior, kept intact).
The reason will be displayed to describe this comment to others. Learn more.
Thanks @julianocosta89 for following-up on this 🙏 could you just shrink the legend control to make room for these new controls, to avoid using more vertical space for this query form, something like this mockup:
Strange to have the same style of inputs. But not the same display (exemplar having a label but not query type) 😕
Well query type controls are quite self explanatory I think, at a glance you understand what "range" and "instant" are related to, so the label isn't mandatory for user comprehension, and adding a "Query type" label in front would consume too much space in the current state imho. But if we want to have similar look & feel across the 2 controls maybe we could go with dropdown+label for each? Like we have for the Query Type dropdown that comes first in the form (oh y btw "Query type" is already taken then 😅 )
Add an optional enableExemplars field to the PrometheusTimeSeriesQuery
spec, rendered as an Auto/On/Off button group in the query editor (same
pattern as the instant toggle):
- Auto (unset): follow the exemplars.enable setting of the datasource
- On/Off: override the datasource setting for this query
- the control is disabled when exemplars are disabled on the selected
datasource or when the query is instant (the exemplars API is
range-based)
- a per-query On cannot override a datasource-level Off
Also adds the field to the CUE schema and a EnableExemplars() option to
the Go SDK query builder.
Signed-off-by: Juliano Costa <julianocosta89@outlook.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The exemplars controls remain enabled with misleading helper text for Auto queries on instant-mode panels, and the On/Off/Auto group lacks an accessible name and exposed selected state.
…3445)
- Name the On/Off/Auto group via aria-labelledby and expose each
button's state with aria-pressed.
- In Auto query mode, note that exemplars are skipped when the panel
runs instant queries. The editor cannot see the panel's query mode,
so it cannot disable the control in that case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KvsQXh9qWa3NMgi9mUQTY3
Signed-off-by: Juliano Costa <julianocosta89@outlook.com>
Exemplars being disabled on the datasource is a configuration state,
not an error, so the label no longer switches to the error colour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KvsQXh9qWa3NMgi9mUQTY3
Signed-off-by: Juliano Costa <julianocosta89@outlook.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The exemplar documentation still incorrectly promises a datasource override and fetching for every range query, and must clarify per-query Auto/On/Off behavior and datasource and range-query requirements.
EnableExemplars(true) cannot enable fetching when the datasource disables exemplars, so this documentation incorrectly promises an override. Document that datasource opt-in remains required, omission follows the datasource setting, and false skips fetching. The same correction is needed in prometheus/src/plugins/prometheus-time-series-query/time-series-query-model.ts:28–30.
Update exemplar docs for the per-query Auto/On/Off option
This changes the documented behavior: docs/prometheus/README.md:137 still says an enabled datasource fetches exemplars with every range query, which is no longer true when enableExemplars is false. Please update the exemplar guide and query model documentation to describe the per-query Auto/On/Off option and clarify that On still requires an enabled datasource and a range query.
enableExemplars can only narrow the datasource setting: true still
requires exemplars enabled on the datasource and a range query.
Document the Auto/On/Off modes in the README and fix the Go and TS
comments that described it as an override.
Signed-off-by: Juliano Costa <julianocosta89@outlook.com>
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
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.
Description
Adds the missing piece of the exemplars MVP from perses/perses#3445: an optional
enableExemplarstoggle on the PrometheusTimeSeriesQuery spec, rendered as an Auto / On / Off button group in the query editor (same pattern as the existinginstanttoggle).Semantics:
exemplars.enablesetting of the selected datasource — the behavior introduced with the MVP.A per-query
Oncannot override a datasource-level off: the effective flag isdatasource.exemplars.enable === true && (spec.enableExemplars ?? true) && !isInstant— exemplars stay a datasource opt-in feature, and they are only fetched for range queries (the exemplars API is range-based).Editor UX:
Also included:
enableExemplars?: boolin the plugin CUE schema.EnableExemplars(bool)option on the Go SDK query builder (mirroringInstant).Screenshots
Query editor with the Exemplars Auto/On/Off toggle:
Full panel editor context:
Testing
getTimeSeriesData:enableExemplars: falsesuppresses the exemplar request even when the datasource enables them;enableExemplars: truedoes not bypass a datasource-level off; instant queries never fetch exemplars (pre-existing behavior, kept intact).tsc --noEmit, oxlint and oxfmt are clean.