Skip to content

[ENHANCEMENT] prometheus: add instant mode to queries#752

Open
SoWieMarkus wants to merge 1 commit into
perses:mainfrom
SoWieMarkus:prometheus-per-query-instant
Open

[ENHANCEMENT] prometheus: add instant mode to queries#752
SoWieMarkus wants to merge 1 commit into
perses:mainfrom
SoWieMarkus:prometheus-per-query-instant

Conversation

@SoWieMarkus

@SoWieMarkus SoWieMarkus commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

This enhancement adds an instant query mode to the Prometheus time series query plugin, allowing individual queries to be executed as instant queries rather than range queries, independent of the panel-level query mode.

Previously, instant queries were only triggered by the panel context's mode field. With this change, a query-level instant flag can be set directly on the PrometheusTimeSeriesQuerySpec, giving users per-query control - similar to how Grafana handles this.

A prior attempt at instant query support (#738) was reverted because it broke the sparkline feature. A follow-up approach (#746) proposed coupling the query mode to the sparkline (instant for the stat value, range for the sparkline), but that approach has a drawback: instant and range queries can e.g. return a different number of time series if a series disappears within the configured time frame, leading to mismatches. This PR sidesteps that problem by attaching the instant flag to the individual query rather than the panel, decoupling it from sparkline behavior entirely. This way, the instant flag gives users explicit, unambiguous control over the query behavior.

Screenshots

Adds an instant toggle to the query:

Bildschirmfoto 2026-07-23 um 22 59 07

instant also disables the sparkline:
Bildschirmfoto 2026-07-23 um 22 59 18

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Signed-off-by: Markus Wieland <markus.wieland@sap.com>
@s3onghyun

Copy link
Copy Markdown

I think your approach is the better one, and it addresses exactly the objection @tgitelman raised on #746.

My PR was constrained by queryOptions returning a single panel-level { mode }: it could only ever pick one mode for the whole panel, so it couldn't give the value an instant query while the sparkline keeps a range query. That's the real fix here, and #746 couldn't express it. Worse, as you and @tgitelman both point out, a single shared range query can be wrong for the value anyway (Loki's split_queries_by_interval, series appearing/disappearing within the window) — so "value correct when sparkline off" was the most #746 could honestly claim, and even that's a narrow slice.

A per-query instant flag on PrometheusTimeSeriesQuerySpec is the right layer: it's explicit, it matches how Grafana does it, and it lets a stat panel run an instant query for the value and a range query for the sparkline as two independent queries. That decouples them properly instead of trying to infer one mode from the spec.

So I'd rather back #752 than push mine. I'll close #746 in favour of it. Two small things from my side that might be worth carrying over:

Nice work — this is the cleaner design.

@celian-garcia

Copy link
Copy Markdown
Member

Cool feature ! Visually I'd vote for a segmented button like Grafana. The advantage is to really know what is the other option.

Screenshot_2026-07-24-08-25-23-61_40deb401b9ffe8e1df2f1cc5ba480b12

https://mui.com/material-ui/react-button-group/

@Nexucis Nexucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your time working on this topic @SoWieMarkus and @s3onghyun ! It is really cool to see the community working together to reach a consensus and bring a good solution to a broader problem.

regarding the go-sdk and the schema it looks good to me.
Over to the frontend maintainers to finish the review even if the changes look reasonable to me :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants