Skip to content

"Logs for this span" does not filter by trace_id, shows all logs for the service instead #779

Description

@ymotongpoo

Description

When clicking "Logs for this span" on a span in the Traces Drilldown app, the resulting Loki query only filters by service_name (and service_namespace), without including a trace_id filter. This causes all logs from the service to be shown instead of only the logs correlated with the selected span/trace.

Steps to Reproduce

  1. Open Traces Drilldown app
  2. Select a trace
  3. Select a span
  4. Click "Logs for this span"

Expected Behavior

The Loki query should include a trace_id filter, e.g.:

{`service_name`="frontend", `service_namespace`="demo"} | `trace_id` = "<`trace_id`>"

Actual Behavior

The generated Loki query only filters by service labels:

{`service_name`="frontend", `service_namespace`="demo"}

No trace_id filter is applied, resulting in all logs from the service being shown.

Additional Context

  • trace_id is stored as Loki structured metadata (not a stream label), which is why {trace_id="..."} cannot be used as a stream selector. A label filter (| trace_id = "...") is required instead.
  • The Tempo datasource "Trace to logs" custom query configuration is ignored by the Traces Drilldown app.
  • Grafana version: 13.1.0 (Cloud Advanced)
  • Traces Drilldown app: grafana-exploretraces-app

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