Skip to content

feat(nimbus): Grafana proxy view#15433

Merged
yashikakhurana merged 11 commits into
mainfrom
iframe_grafana_test
May 21, 2026
Merged

feat(nimbus): Grafana proxy view#15433
yashikakhurana merged 11 commits into
mainfrom
iframe_grafana_test

Conversation

@yashikakhurana

@yashikakhurana yashikakhurana commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Because

-Grafana is behind Google IAP, which sets session cookies on yardstick.mozilla.org. Browsers block these as third-party cookies when the dashboard is embedded in an iframe on a different origin, causing it to fail to load.

This commit

  • Adds a server-side GrafanaProxyView that fetches Grafana content via internal k8s DNS (grafana.grafana-prod.svc.cluster.local:8080), bypassing IAP entirely
  • Rewrites and appUrl in HTML responses so Grafana's assets and API calls also route through the proxy
  • Adds GRAFANA_INTERNAL_URL and GRAFANA_SERVICE_ACCOUNT_TOKEN settings for the internal endpoint and service account auth
  • Adds feature_monitoring_proxy_path on NimbusFeatureConfig to extract the path/query from the monitoring URL
    Updates the feature monitoring iframe to use /nimbus/grafana-proxy/ instead of the direct Grafana URL

Fixes #15342
https://github.com/mozilla/webservices-infra/pull/10728

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

Oh that's a clever idea! I think there's a bunch to talk through on this so let's chat about it on Monday.

@yashikakhurana

Copy link
Copy Markdown
Contributor Author

Blocking this now as we discussed to do a security review first before adding this

@yashikakhurana

Copy link
Copy Markdown
Contributor Author

cleared from the security review, got approval

Comment thread experimenter/experimenter/nimbus_ui/views.py Outdated
Yashika Khurana and others added 5 commits May 19, 2026 16:59
…y security

- Embed the Grafana monitoring iframe directly in the Feature Health
  Dashboard (features.html) instead of a dedicated separate page
- Remove NimbusFeatureMonitoringView and feature_monitoring.html since
  the monitoring now lives on the feature page as originally intended
- Fix security issue: GrafanaProxyView now accepts ?slug= for dashboard
  requests, validates it against the DB, and constructs the upstream URL
  internally so user input never controls the proxy target path
- Asset requests (JS/CSS) continue to use path-based proxy as before
…t URL from settings

Addresses security review: removes path parameter injection risk by validating
slug against DB and building the Grafana URL entirely from settings constants.
@yashikakhurana

Copy link
Copy Markdown
Contributor Author

@jaredlockhart this is ready for review now

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

Alright let's give it a shot let's gooooo 🎉 🔥 🎉 🔥 🎉 🔥 🎉 🔥

Comment thread experimenter/experimenter/nimbus_ui/views.py Outdated
class="btn btn-outline-primary btn-sm">
<i class="fa-solid fa-arrow-up-right-from-square me-1"></i>
Open in Grafana
</a>

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.

Yeah exactly I think it's better to link front and centre out to external dashboards, people will miss the links if they're in the sidebar.

Comment on lines +1150 to +1155
def get(self, request):
slug = request.GET.get("slug")
if not slug:
return HttpResponse("Missing slug parameter", status=400)

feature_config = get_object_or_404(NimbusFeatureConfig, slug=slug)

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.

Yeah so we can do this like this, where we just receive GET and then naively unpack the slug field and do get_object_or_404 ourselves. But you can also mix in something like the SingleObjectMixin that does all that for you, and then it'll catch like extra cases and raise additional codes where necessary etc, it just does a lot of the plumbing for you. This is totally fine to just leave as is I just wanted to highlight ways that Django gives you pieces that does things like this for you that you can easily drop in.

Comment on lines +1169 to +1172
"timezone": "utc",
"var-application": application,
"var-feature": feature_config.slug,
"kiosk": "",

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.

Are we gonna have to pass through the light/dark mode theme? 🤔

</div>
<div class="card shadow-sm border-0 rounded-3 mb-3">
<div class="card-body p-0">
<iframe src="/nimbus/grafana-proxy/?slug={{ selected_feature_config.slug }}"

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.

So yeah let's land this as a prototype just to show that the graph renders etc. But next we'll probably have to

  • Discover the list of metrics for a feature (which we can discover by pulling in teh feature metric config files that are in metric hub now, they might already even be pulled in via the config update? 🤔 )
  • Loop over them and create one iframe per metric
  • Pass that metric in through the url
    But we an do that as a followup

Or if you can 'select all' by default so we get all the metrics for the feature automatically try that 🙏

Comment thread experimenter/experimenter/nimbus_ui/views.py Outdated
@yashikakhurana yashikakhurana enabled auto-merge May 21, 2026 18:37
@yashikakhurana yashikakhurana added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 49ec752 May 21, 2026
26 checks passed
@yashikakhurana yashikakhurana deleted the iframe_grafana_test branch May 21, 2026 19:44
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.

Show Grafana metric graphs on experimenter feature page

2 participants