Skip to content

[BUGFIX] Statchart: request instant queries for stat panels#738

Merged
jgbernalp merged 1 commit into
perses:mainfrom
tgitelman:fix/statchart-instant-query-mode
Jul 21, 2026
Merged

[BUGFIX] Statchart: request instant queries for stat panels#738
jgbernalp merged 1 commit into
perses:mainfrom
tgitelman:fix/statchart-instant-query-mode

Conversation

@tgitelman

Copy link
Copy Markdown
Contributor

Summary

Ref: perses/perses#4270

StatChart never sets queryOptions.mode, so the query plugin defaults
to range queries (query_range). Stat panels display a single aggregate
value (last, sum, avg, etc.) and have no use for time-series data points
— they should request instant queries instead.

This is consistent with TimeSeriesTable and HistogramChart which
already set queryOptions: { mode: 'instant' }.

Changes

statchart/src/StatChart.ts:

  • Add queryOptions: { mode: 'instant' } to the StatChart panel plugin definition

Reproduction

  1. Add a StatChart panel with an aggregate query (e.g. count_over_time(... [$__range]))
  2. Before fix: panel sends query_range — datasource returns multiple data points, only one is used
  3. After fix: panel sends query (instant) — datasource returns a single correct value

Test plan

  • StatChart panels request instant queries (verified via datasource logs showing query_type=instant)
  • Time series charts (which need range queries) are unaffected
  • Consistent with existing TimeSeriesTable and HistogramChart behavior

@Gladorme Gladorme 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.

Make sense to me to be instant query. Thanks!
You will need to sign commit to pass DCO :)

StatChart never sets queryOptions.mode, so the query plugin defaults to
range queries (query_range). Stat panels display a single aggregate
value (last, sum, avg, etc.) and have no use for time-series data
points — they should request instant queries instead.

This is consistent with TimeSeriesTable and HistogramChart which already
set queryOptions: { mode: 'instant' }.

Ref: perses/perses#4270
Signed-off-by: Tal Gitelman <tgitelma@redhat.com>
@tgitelman
tgitelman force-pushed the fix/statchart-instant-query-mode branch from 0db1cdd to f2f7c06 Compare July 21, 2026 09:19
@jgbernalp
jgbernalp enabled auto-merge July 21, 2026 09:41
@jgbernalp jgbernalp changed the title fix(statchart): request instant queries for stat panels [BUGFIX] Statchart: request instant queries for stat panels Jul 21, 2026
@jgbernalp
jgbernalp added this pull request to the merge queue Jul 21, 2026
Merged via the queue into perses:main with commit 3e3b7ae Jul 21, 2026
16 checks passed
@Gladorme

Gladorme commented Jul 21, 2026

Copy link
Copy Markdown
Member

I forgot the sparkline behavior, without range data, it will break. Stat chart need to support both instant and range. We will need to revert the PR

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.

3 participants