Make the Grafana metrics link runtime configurable - #808
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe Admin UI now retrieves a validated Grafana URL from the API, falls back to a build-time value when needed, and exposes the dashboard from the Metrics tab. Compose, Nginx, Prometheus, Grafana, GPU exporter, Helm, and documentation configurations are updated accordingly. ChangesGrafana metrics integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SystemPage
participant ConfigAPI
participant Nginx
participant Grafana
participant Prometheus
SystemPage->>ConfigAPI: Request runtime Grafana configuration
ConfigAPI-->>SystemPage: Return validated grafana_url
SystemPage->>Nginx: Open Grafana metrics link
Nginx->>Grafana: Proxy /grafana/ request
Grafana->>Prometheus: Query nvidia_smi metrics
Prometheus-->>Grafana: Return metric data
Grafana-->>SystemPage: Render dashboard
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b16d3e4b47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/assets/env_example.env`:
- Around line 108-111: The proxied Grafana examples use inconsistent URLs. In
docs/assets/env_example.env lines 108-111, update GRAFANA_URL to the
browser-facing /grafana/d/... path; in docs/assets/env_linux_gpu.env lines
55-58, update the runtime URL to match the documented /grafana/ route.
In `@infra/compose/.env.example`:
- Around line 108-111: Update the Grafana environment examples around
GRAFANA_URL and GF_SERVER_ROOT_URL so they are internally consistent: either set
GRAFANA_URL to the Admin UI /grafana/ path when using the proxied
GF_SERVER_ROOT_URL configuration, or clearly provide separate direct-origin and
proxied examples.
In `@infra/compose/grafana/dashboards/gpu-metrics.json`:
- Around line 77-78: Remove the * 100 scaling from the GPU utilization
expression at infra/compose/grafana/dashboards/gpu-metrics.json lines 77-78, and
from the utilization gauge and memory-controller utilization expressions at
lines 167-168 and 350-351. Keep each metric query otherwise unchanged so the
dashboards display the exported 0–1 ratios directly.
In `@openrag/api/runtime_ui.py`:
- Around line 18-20: Update the Grafana URL parsing logic around urlparse to
catch ValueError from malformed netlocs or ports, and require parsed.hostname in
addition to an HTTP(S) scheme before returning the value. Ensure invalid
GRAFANA_URL values safely produce the existing fallback result without raising
while building /config.
- Around line 15-16: Update the relative-path validation around the value check
to reject any string containing a backslash before returning it as same-origin;
preserve the existing slash-prefix and double-slash handling, and add a
regression test covering a path such as “/\evil.example”.
In `@ui/README.md`:
- Around line 40-44: Update the surrounding settings documentation in the README
to state that the listed VITE_* variables are build-time settings, while
preserving the paragraph explaining GRAFANA_URL as an OpenRAG API runtime
setting. Ensure the wording does not imply that GRAFANA_URL is a Vite build-time
configuration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 91fecfaa-1e0d-4da4-9e28-93695af24dd2
📒 Files selected for processing (20)
docs/assets/env_example.envdocs/assets/env_linux_gpu.envdocs/content/docs/documentation/env_vars.mdinfra/charts/openrag-stack/values.yamlinfra/compose/.env.exampleinfra/compose/docker-compose.yamlinfra/compose/grafana/dashboards/gpu-metrics.jsoninfra/compose/monitoring.docker-compose.yamlinfra/compose/nginx/openrag-admin.confinfra/compose/prometheus/prometheus.ymlinfra/docker/api.Dockerfileopenrag/api/main.pyopenrag/api/runtime_ui.pytests/unit/api/test_runtime_ui.pyui/.env.exampleui/README.mdui/src/lib/api/system.tsui/src/mocks/handlers.tsui/src/pages/admin/system.test.tsxui/src/pages/admin/system.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/content/docs/installation/docker.mdx`:
- Around line 28-33: Replace the source .env flow in the Docker installation
instructions with Compose-dotenv-aware parsing or direct validation that does
not execute shell code, while correctly supporting valid dotenv values such as
spaces. Preserve exporting or retrieving AUTH_TOKEN for writing
prometheus/openrag_token, and enforce that it is present unless ALLOW_NO_AUTH is
enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: af252e33-6832-4531-9960-65d1125a2351
📒 Files selected for processing (8)
.gitignoredocs/assets/env_example.envdocs/assets/env_linux_gpu.envdocs/content/docs/installation/docker.mdxinfra/compose/.env.exampleopenrag/api/runtime_ui.pytests/unit/api/test_runtime_ui.pyui/README.md
🚧 Files skipped from review as they are similar to previous changes (5)
- openrag/api/runtime_ui.py
- docs/assets/env_linux_gpu.env
- infra/compose/.env.example
- docs/assets/env_example.env
- ui/README.md
Closes #779
Context
Operators need a clear path from OpenRAG raw metrics to the deployment dashboard without knowing the Grafana address or rebuilding the Admin UI.
Problem
A build-time-only link does not work reliably with prebuilt images. Hiding the action when runtime configuration is missing also makes the Grafana capability impossible to discover from the Metrics screen.
Solution
System → Metrics now always shows one Open in Grafana action. When the deployment provides a valid dashboard destination, it opens in a new tab. When configuration is missing, the same action explains how to enable it. Compose and Helm deployments can provide the destination through
GRAFANA_URL, while the previous build-time setting remains a compatibility fallback.Validation
All 160 Admin UI tests pass, the production UI build succeeds, and the backend runtime-configuration tests pass. Linting completes without new errors.
Summary by CodeRabbit
/grafana/routing/proxy.grafana_urlin the Admin config response; added corresponding Helm/Compose and environment templates.