Skip to content

fix(dashboards): Grafana gallery follow-ups from #592 (#596) - #598

Merged
caohy1988 merged 3 commits into
GoogleCloudPlatform:mainfrom
dsprakash-cloud:grafana-gallery-followups
Nov 24, 2026
Merged

caohy1988 merged 3 commits into
GoogleCloudPlatform:mainfrom
dsprakash-cloud:grafana-gallery-followups

Conversation

@dsprakash-cloud

Copy link
Copy Markdown
Contributor

Closes #596. Follow-up to #592, in three commits. Please keep them separate when merging (Rebase and merge).

1. fix(dashboards): percent-encode the timezone in the trace link

The link now uses timezone=${__timezone:percentencode} instead of timezone=${__timezone}, so fixed-offset zones keep their +. Before, Etc/GMT+5 reached the new tab as Etc/GMT 5. The link test now round-trips utc, Etc/GMT+5, Etc/GMT-14 and America/Argentina/Buenos_Aires. The gallery copy is regenerated with Grafana 12.3.4 in the same commit, and only the timezone token differs. SHA-256 7b91b27f3e6308fd19e70aa6daff847664ea45aa6e182688a2c2c2105ccd1122.

2. test(dashboards): diff the whole gallery export against the trial

tests/test_grafana_gallery_export.py now diffs every panel, variable and dashboard setting, and fails on any difference the export doesn't explain. The allowed rewrites are listed in the file:

  • Defaults Grafana 12.3 fills in, each with its exact value (FILLED_DEFAULTS).
  • Three schema-migration changes: the base threshold step written as 0 or dropped, a hidden table footer moved into the field defaults, and hideFrom.tooltip set on series that are already hidden from the viz.
  • The export's own changes: __inputs references, cleared query-variable state, and dropped keys that only restated a default.

Sanitization is checked separately:

  • Query variables keep no current or options.
  • Constants keep only their VAR_* reference.
  • The datasource input is exactly DS_BIGQUERY, labelled "BigQuery".
  • __requires lists only Grafana ≥ 12.3.4 and the plugin version run_local.py pins.
  • No URLs, credentials or hosts.

Each of these mutations of the gallery file now fails the test, and the unmodified file passes:

  • panel 12's reducer field set to /^llm_calls$/
  • a latency series relabelled
  • every __requires version downgraded
  • the plugin version removed
  • a real project id in a constant's current
  • a saved session in the Session variable's current, and in its options
  • a datasource input named after an instance
  • a URL in a description
  • a threshold changed
  • allowCustomValue flipped
  • a series hidden from the tooltip

3. docs(dashboards): keep the raw Grafana export inside gallery/

The regeneration steps now save the download as dashboards/grafana/gallery/exported.json, which is ignored, and delete it after the jq step. The ignore rule is now gallery/**/*.json with the matching *.gallery.json exception, and the README says what it covers.

Checks

  • Tests: tests/test_grafana_efficiency_trial.py, tests/test_grafana_gallery_export.py, tests/test_check_grafana_queries_sync.py and tests/test_grafana_local_runner.py give 202 passed. scripts/check_grafana_queries_sync.py passes, and autoformat.sh makes no changes.
  • The Publish BQAA Grafana dashboard to the grafana.com dashboards gallery #566 pre-submission checklist (scripted) passes 37 of 37.
  • On a clean Grafana 12.3.4 with plugin 3.3.1 and seeded synthetic data:
    • The import returned 200, and all 18 queries returned with no errors.
    • Switching the data source moved all 18 queries.
    • The drill-down showed only the clicked session.
    • Org pinning still works.
    • With the dashboard on Etc/GMT+5, the new tab shows Trace detail five hours behind UTC. The old link, with a raw +, showed UTC times.

Not changed here: the pre-existing ___ALL___ sentinel that #596 notes, where a session whose id is literally ___ALL___ matches every session.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for working through the #592 follow-ups. The gallery export still matches the trial dashboard, datasource references only go through the input, and the drift tests pass and do catch the obvious bad exports. Approving.

There are a few things I'd still like tightened in a follow-up. The most important is first-load behavior after a fresh gallery import: the Session variable starts empty and its option query allows "", so a table with any empty session ID can open filtered down to just those events. The rest are mostly gaps in the drift tests (duplicate entries, nested panels, booleans vs numbers) and the README regeneration steps. I'll put them in a separate issue.

The Recent sessions link passed timezone=${__timezone}, which Grafana's
default URL formatting leaves unencoded. With the dashboard on a fixed-offset
zone such as Etc/GMT+5, the link carried timezone=Etc/GMT+5, and the new tab
read the "+" as a space ("Etc/GMT 5") and showed Trace detail in another zone.
${__timezone:percentencode} sends timezone=Etc%2FGMT%2B5.

The link tests check that utc, Etc/GMT+5, Etc/GMT-14 and a three-part zone
round-trip. The gallery copy is regenerated with Grafana 12.3.4 in the same
commit; only the link's timezone token differs (SHA-256 7b91b27f3e6308fd19e70aa6daff847664ea45aa6e182688a2c2c2105ccd1122).

Checked on a clean Grafana 12.3.4 with plugin 3.3.1: with the dashboard on
Etc/GMT+5, the link carries timezone=Etc%2FGMT%2B5 and the new tab shows Trace
detail five hours behind UTC, while the same link with the raw "+" does not.

Part of GoogleCloudPlatform#596.
tests/test_grafana_gallery_export.py compared queries, data sources and a
chosen set of fields, so a changed reducer field, a relabelled series, a
downgraded or missing __requires version, or a value saved in a variable's
state still passed. It now diffs every panel, variable and dashboard setting
and fails on any difference the export does not explain. The allowed
rewrites are listed in the file:

- defaults Grafana 12.3 fills in, each with its exact value
  (FILLED_DEFAULTS), plus pluginVersion and 0..1 bounds on a percentunit
  field;
- schema-migration changes: the base threshold step written as 0 or dropped,
  a hidden table footer moved into field defaults, and hideFrom.tooltip set
  on series already hidden from the viz;
- the export's own changes: constants and the data source become __inputs
  references, query variables lose their selection, and keys that only
  restate a default (hide 0, skipUrlSync false, sort 0, liveNow false) are
  dropped.

Sanitization is checked on its own: query variables keep no current value or
options; constants keep only their VAR_* reference in query, current and
options; the data source input is exactly DS_BIGQUERY, labelled "BigQuery";
__requires lists only Grafana 12.3.4 or later and the plugin version
run_local.py pins; and the file has no URLs, credentials or hosts.

Each regression listed in GoogleCloudPlatform#596 now fails the test, as do a few more: the
reducer field, a series label, __requires versions, a missing plugin version,
a constant's current value, a saved session, a datasource input named after
an instance, a URL, a threshold, allowCustomValue and a changed default.

Part of GoogleCloudPlatform#596.
The regeneration steps had jq read exported.json from the repository root,
which .gitignore does not cover, so git add -A could stage a raw export with
real project and dataset names. The steps now save the download as
dashboards/grafana/gallery/exported.json and delete it afterwards.

The ignore rule matched only direct children of gallery/, although the README
said every other JSON file there is ignored. It now uses gallery/**/*.json
with the matching *.gallery.json exception, and the README's note on keys
says what it covers.

Part of GoogleCloudPlatform#596.
@caohy1988
caohy1988 force-pushed the grafana-gallery-followups branch from 042fcd3 to 4f371f1 Compare November 23, 2026 23:47
@caohy1988
caohy1988 merged commit 9a995bf into GoogleCloudPlatform:main Nov 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants