Log panel adds non-working quick filter for structured metadata filter

In the Grafana log panel, I can click on a log line and see the indexed labels, structured metadata and parsed fields. The structured metadata and parsed fields have filter buttons on them, but when used they are added as label filters, so they never match (they’re not labels).

Is there some way to make Grafana add these correctly as label filter expressions instead, or disable the filter buttons since they don’t work?

I tested this on Grafana 13.0.1 with Loki using parsed JSON fields. Clicking the filter button generated a proper LogQL field filter

{job="demo"} | json | remote_ip="10.1.2.3"


rather than a label selector such as:

{job="demo", remote_ip="10.1.2.3"}

which would indeed fail if remote_ip is not a label.

I didn’t get the issue. It may be version-specific or related specifically to structured metadata. Could you share
Grafana version
Loki version
An example of the query generated after clicking the filter button
That would help determine whether this is a bug or a configuration/version difference.

Interesting. I see you are using Explore. I tried it there and it worked, adding a quick filter on a particular structured metadata value correctly resulted in

{service_name="webapp", instance="dbtest1"} | session_id=`f91f07ff-bfd3-41a6-94d3-3bbef69a3633` |= ```

It isn’t working in a dashboard using the log panel though.

I’m using Grafana 13.0.2, connected to loki on Grafana Cloud.

This seems to be this issue here - Ad hoc filters for query output · Issue #109470 · grafana/grafana · GitHub

More relevant github issue here - Loki: Adhoc filters break when filtering for structured metadata · Issue #93394 · grafana/grafana · GitHub

Adding a log line parser to the query helps - just add | logfmt, even though I’m not using logfmt.

This is a issue in Grafana .When clicking filter buttons on structured metadata or parsed fields in the log panel on a dashboard, Grafana incorrectly adds them as stream selectors {field="value"} instead of label filter expressions | field="value".

Add a parser stage to your query:

{job="demo"} | logfmt

After adding the parser, the filter button will correctly generate:

{job="demo"} | logfmt | remote_ip="10.1.2.3"

This only affects the log panel in dashboards — the Explore view works correctly.