grafana / explore-logs

Repo for the Loki log exploration app
GNU Affero General Public License v3.0
308 stars 14 forks source link

Structured metadata: Refactor into new variable #826

Closed gtk-grafana closed 1 month ago

gtk-grafana commented 1 month ago

This PR moves structured metadata fields into a dedicated scenes variable. This enables us to have more control over how metadatafields are interpolated in the query, allowing us to place all metadata before any log parsers, which will result in more efficient/optimal queries.

There should be no changes to the UI, just the queries that are sent to Loki.

We still have a potential race condition where users can filter results in the table/logs panel before the detected_fields response which will give us the parser, in these cases we will fall back to adding fields with "unknown" parsers to the fields variable, and require both logfmt and json parsers for queries with that field. Created https://github.com/grafana/explore-logs/issues/837 to track

matyax commented 1 month ago

Taking a look.

matyax commented 1 month ago

Yeah, great catch. We need to update https://github.com/grafana/explore-logs/blob/main/src/Components/ServiceScene/LogsPanelScene.tsx#L125-L176

gtk-grafana commented 1 month ago

@svennergr @matyax Good catch, that bug has likely been hanging out since we added detected_fields. Should be fixed now in https://github.com/grafana/explore-logs/pull/826/commits/b643f482c1731757ab59979f0a3e0b9c9c841308

matyax commented 1 month ago

I pulled the latest changes and still don't see the active state:

imagen