Description
When navigating from a trace span to logs, the generated link does not respect the Grafana root_url configuration. When Grafana is deployed under a sub-path (e.g., http://example.com/grafana), the logs drilldown link is missing the appSubUrl prefix, resulting in a 404.
Steps to Reproduce
- Configure Grafana's
root_url to include a sub-path (e.g., http://example.com/grafana)
- Open Traces Drilldown and view a trace by its ID
- Click a link from a span to navigate to logs
- Observe that the link is missing the
/grafana prefix and fails to navigate
Expected Behavior
The link should include the appSubUrl prefix, e.g.: /grafana/a/grafana-lokiexplore-app/explore?...
Actual Behavior
The link is missing the prefix, e.g.: /a/grafana-lokiexplore-app/explore?...
Root Cause
In DataLinksCustomContext.tsx, the path returned by the Logs Drilldown plugin via the grafana-exploretraces-app/get-logs-drilldown-link/v1 extension point is assigned directly to linkModel.href without prepending config.appSubUrl.
Other navigation links in the codebase (e.g., PanelMenu.tsx, SpanListScene.tsx) correctly prepend config.appSubUrl:
const subUrl = config.appSubUrl ?? '';
const url = urlUtil.renderUrl(`${subUrl}/explore`, { ... });
Fix
Prepend config.appSubUrl to extensionLink.path before assigning it to linkModel.href in DataLinksCustomContext.tsx:
// Before
linkModel.href = extensionLink.path;
// After
const subUrl = config.appSubUrl ?? '';
linkModel.href = `${subUrl}${extensionLink.path}`;
Affected Files
src/pages/Explore/DataLinksCustomContext.tsx
src/pages/Explore/DataLinksCustomContext.test.tsx
Description
When navigating from a trace span to logs, the generated link does not respect the Grafana
root_urlconfiguration. When Grafana is deployed under a sub-path (e.g.,http://example.com/grafana), the logs drilldown link is missing theappSubUrlprefix, resulting in a 404.Steps to Reproduce
root_urlto include a sub-path (e.g.,http://example.com/grafana)/grafanaprefix and fails to navigateExpected Behavior
The link should include the
appSubUrlprefix, e.g.:/grafana/a/grafana-lokiexplore-app/explore?...Actual Behavior
The link is missing the prefix, e.g.:
/a/grafana-lokiexplore-app/explore?...Root Cause
In
DataLinksCustomContext.tsx, thepathreturned by the Logs Drilldown plugin via thegrafana-exploretraces-app/get-logs-drilldown-link/v1extension point is assigned directly tolinkModel.hrefwithout prependingconfig.appSubUrl.Other navigation links in the codebase (e.g.,
PanelMenu.tsx,SpanListScene.tsx) correctly prependconfig.appSubUrl:Fix
Prepend
config.appSubUrltoextensionLink.pathbefore assigning it tolinkModel.hrefinDataLinksCustomContext.tsx:Affected Files
src/pages/Explore/DataLinksCustomContext.tsxsrc/pages/Explore/DataLinksCustomContext.test.tsx