Skip to content

fix: log panel flickering in Grafana 12.3+ with newLogsPanel virtualization#174

Open
hatemosphere wants to merge 1 commit intoquickwit-oss:mainfrom
hatemosphere:fix/log-panel-flickering
Open

fix: log panel flickering in Grafana 12.3+ with newLogsPanel virtualization#174
hatemosphere wants to merge 1 commit intoquickwit-oss:mainfrom
hatemosphere:fix/log-panel-flickering

Conversation

@hatemosphere
Copy link

Summary

Fixes log panel flickering/row overlap in Grafana 12.3+ caused by three issues in how the plugin returns data frames to Grafana's new virtualized log panel (newLogsPanel, GA since 12.3).

Root cause

Grafana 12.3 introduced a virtualized log list that caches row heights by LogRowModel.uid. The uid is ${refId}_${idField.values[row]}. Without an id field, all rows shared uid A_null, causing the height cache to oscillate between different row heights in an infinite resetAfterIndex loop (13k+ calls/sec = visible flickering).

Additionally, sortPropNames ignored the shouldSortLogMessageField parameter, so logMessageField was sorted alphabetically instead of being placed first. Grafana picks the log body via getFirstFieldOfType(FieldType.string), so wrong field order = wrong body field = wrong height measurement.

Changes

pkg/quickwit/response_parser.go:

  • Add unique id field per log row (sequential index as fallback when doc has no id), matching Elasticsearch behavior where each hit has _id/id. Grafana's parseLegacyLogsFrame uses this for LogRowModel.uid, which the virtualizer uses as height cache key.
  • Fix sortPropNames to actually sort logMessageField to first position when shouldSortLogMessageField is true, matching the Grafana built-in Elasticsearch datasource implementation.

src/datasource/processResponse.ts:

  • Remove synthetic $qw_message field injection — now redundant since Go backend correctly sorts logMessageField first.
  • Fix data links array spread bug: [...(a || [], b)] (comma operator, drops existing links) → [...(a || []), ...b].

src/datasource/supplementaryQueries.ts:

  • Migrate from deprecated getDataProvider() to getSupplementaryRequest() API. The old code created an Observable that emitted {data: []} on every subscription. Matches how Grafana's built-in ES and Loki datasources work.

Test plan

  • Reproduced flickering locally with prod Quickwit data + Grafana 12.4.1
  • Confirmed ES datasource does NOT flicker with same data (0 resetAfterIndex calls vs 13k+/sec for QW)
  • Verified fix locally: unique id field → unique uids → no more infinite loop → no flickering
  • Verified message field correctly sorted to first position in frame

…zation

Grafana 12.3 introduced a virtualized log list (newLogsPanel, GA) that
caches row heights by LogRowModel.uid. The uid is derived from the frame's
"id" field: uid = "${refId}_${idField.values[row]}".

Three issues caused flickering:

1. No "id" field in frames → all rows shared uid "A_null" → height cache
   oscillated between different row heights → infinite resetAfterIndex
   loop (13k+ calls/sec = visible flickering). Fix: generate unique id
   per row, matching ES behavior.

2. sortPropNames ignored shouldSortLogMessageField → logMessageField
   sorted alphabetically instead of first → Grafana picked wrong body
   field → wrong height measurement. Fix: match ES datasource behavior.

3. processResponse.ts injected synthetic $qw_message field, adding an
   extra field to frames. Fix: remove injection, Go backend now handles
   field ordering. Also fix data links spread bug (comma operator).

Additionally migrated from deprecated getDataProvider() to
getSupplementaryRequest() API, matching ES/Loki datasources.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hatemosphere hatemosphere force-pushed the fix/log-panel-flickering branch from 2e509c5 to 79efcf6 Compare March 25, 2026 11:56
@hatemosphere
Copy link
Author

hatemosphere commented Mar 25, 2026

@Platane hey, any chances you could look at this? with 12.3+ plugin is mostly unusable
we rolled this out on all our 12.4.1 instances couple of days ago, and i've already pushed another small change fixing small bug with viewing ranges with 0 logs. anything i could add to PR to simplify reviewing it etc?

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.

1 participant