Skip to content

[Dashboard] Fix invalid PromQL when global_filters is empty in Grafana dashboard generation#63687

Merged
edoakes merged 3 commits into
ray-project:masterfrom
liujp:liujp/fix-empty-global-filters
May 28, 2026
Merged

[Dashboard] Fix invalid PromQL when global_filters is empty in Grafana dashboard generation#63687
edoakes merged 3 commits into
ray-project:masterfrom
liujp:liujp/fix-empty-global-filters

Conversation

@liujp

@liujp liujp commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

Fix Serve LLM Grafana dashboard failing to load due to invalid PromQL syntax.

The Serve LLM dashboard (serve_llm_dashboard_panels.py) sets standard_global_filters=[]. When the environment variable RAY_GRAFANA_SERVE_LLM_DASHBOARD_GLOBAL_FILTERS is also not set, {global_filters} in panel expressions is replaced with an empty string, producing invalid PromQL with double commas:

Clipboard_Screenshot_1779942646

Generated invalid expression - Grafana fails to load

ray_serve_deployment_request_counter_total{model_name="$vllm_model_name", , deployment="$deployment"}

This PR adds post-format regex cleanup in _generate_targets() to remove empty filter artifacts:

  • , , → ,
  • , } → }
  • { , → {

These patterns are never valid in PromQL, so other dashboards with non-empty filters are unaffected.

@liujp liujp requested a review from a team as a code owner May 28, 2026 04:31
@liujp liujp changed the title Title: [Dashboard] Fix invalid PromQL when global_filters is empty in Grafana dashboard generation May 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces regex-based cleanup for empty global filters in PromQL expressions to prevent invalid syntax. The reviewer pointed out that running these regex replacements unconditionally is risky as it could corrupt valid queries (e.g., within quoted strings). They suggested wrapping the cleanup in a check to only run when global_filters_str is empty, and noted that dashboard variables may also require a similar cleanup.

Comment thread python/ray/dashboard/modules/metrics/grafana_dashboard_factory.py Outdated
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue core Issues that should be addressed in Ray Core observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling community-contribution Contributed by the community labels May 28, 2026
@liujp liujp force-pushed the liujp/fix-empty-global-filters branch from 78fba03 to 014a8cf Compare May 28, 2026 08:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 014a8cf. Configure here.

Comment thread python/ray/dashboard/modules/metrics/grafana_dashboard_factory.py Outdated
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label May 28, 2026

@edoakes edoakes 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 the contribution

@edoakes edoakes merged commit 3e73896 into ray-project:master May 28, 2026
7 checks passed
@andrewsykim andrewsykim added the backport-candidate Label to identify PRs that should be considered for backport to older versions. label May 29, 2026
rueian pushed a commit to rueian/ray that referenced this pull request Jun 4, 2026
…a dashboard generation (ray-project#63687)

Description

Fix Serve LLM Grafana dashboard failing to load due to invalid PromQL
syntax.

The Serve LLM dashboard (serve_llm_dashboard_panels.py) sets
standard_global_filters=[]. When the environment variable
RAY_GRAFANA_SERVE_LLM_DASHBOARD_GLOBAL_FILTERS is also not set,
{global_filters} in panel expressions is replaced with an empty string,
producing invalid PromQL with double commas:

<img width="1785" height="414" alt="Clipboard_Screenshot_1779942646"
src="https://github.com/user-attachments/assets/9038d10e-fe51-4759-8df4-c505ac3ad2df"
/>

  # Generated invalid expression - Grafana fails to load

ray_serve_deployment_request_counter_total{model_name=~"$vllm_model_name",
, deployment=~"$deployment"}

This PR adds post-format regex cleanup in _generate_targets() to remove
empty filter artifacts:
  - , , → ,
  - , } → }
  - { , → {

These patterns are never valid in PromQL, so other dashboards with
non-empty filters are unaffected.

---------

Signed-off-by: liujp <715643011@qq.com>
limarkdcunha pushed a commit to limarkdcunha/ray that referenced this pull request Jun 30, 2026
…a dashboard generation (ray-project#63687)

Description

Fix Serve LLM Grafana dashboard failing to load due to invalid PromQL
syntax.

The Serve LLM dashboard (serve_llm_dashboard_panels.py) sets
standard_global_filters=[]. When the environment variable
RAY_GRAFANA_SERVE_LLM_DASHBOARD_GLOBAL_FILTERS is also not set,
{global_filters} in panel expressions is replaced with an empty string,
producing invalid PromQL with double commas:

<img width="1785" height="414" alt="Clipboard_Screenshot_1779942646"
src="https://github.com/user-attachments/assets/9038d10e-fe51-4759-8df4-c505ac3ad2df"
/>

  # Generated invalid expression - Grafana fails to load

ray_serve_deployment_request_counter_total{model_name=~"$vllm_model_name",
, deployment=~"$deployment"}

This PR adds post-format regex cleanup in _generate_targets() to remove
empty filter artifacts:
  - , , → ,
  - , } → }
  - { , → {

These patterns are never valid in PromQL, so other dashboards with
non-empty filters are unaffected.

---------

Signed-off-by: liujp <715643011@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate Label to identify PRs that should be considered for backport to older versions. community-contribution Contributed by the community core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling serve Ray Serve Related Issue

3 participants