Skip to content

Trace-to-logs link ignores Grafana root URL (appSubUrl) configuration #784

Description

@okhowang

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

  1. Configure Grafana's root_url to include a sub-path (e.g., http://example.com/grafana)
  2. Open Traces Drilldown and view a trace by its ID
  3. Click a link from a span to navigate to logs
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions