Conversation
Different managed Grafana deployments support different datasource proxy endpoints: Azure requires /resources while AWS requires /proxy. When the primary endpoint returns 403 or 500, automatically retry with the alternate endpoint and cache the result for subsequent requests. Fixes #524 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MCP Token Analysis✅ Passed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
datasourceFallbackTransportthat automatically retries with the alternate datasource proxy endpoint when the primary returns 403 or 500/api/datasources/uid/{uid}/resourcesfirst, falls back to/api/datasources/proxy/uid/{uid}/api/datasources/proxy/uid/{uid}first, falls back to/api/datasources/uid/{uid}/resourcesContext
Different managed Grafana deployments support different datasource proxy endpoints:
/api/datasources/uid/{uid}/resources(the/proxypath returns 403)/api/datasources/proxy/uid/{uid}(the/resourcespath returns 500 for POST)PR #483 switched Prometheus to
/resourcesto fix Azure, but this broke AWS. This PR makes both work transparently.Test plan
Fixes #524
🤖 Generated with Claude Code
Note
Medium Risk
Touches core HTTP request routing for Prometheus/Loki datasource calls and adds automatic retry/caching behavior, which could mask real 403/500s or change request semantics if path rewriting/body replay has edge cases.
Overview
Adds a new
datasourceFallbackTransporthttp.RoundTripperthat rewrites datasource request paths and automatically retries against an alternate endpoint on403or500, buffering/replaying request bodies and caching which base path requires fallback to avoid repeated failures.Updates Prometheus and Loki clients to build datasource base paths via
datasourceProxyPathsand wrap their HTTP transports with this fallback logic (Prometheus:/resources->/proxy; Loki:/proxy->/resources) to improve compatibility across managed Grafana deployments.Written by Cursor Bugbot for commit c0c0e37. This will update automatically on new commits. Configure here.