grafana / explore-logs

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

Service selection scene: filter logs by the selected level in the chart #473

Closed matyax closed 2 weeks ago

matyax commented 2 weeks ago

This PR adds support for applying a level filter to the logs preview we show in the service selection.

Demo:

https://github.com/grafana/explore-logs/assets/1069378/34bb039a-ce56-457f-9ad1-27d452a5ac75

gtk-grafana commented 2 weeks ago

Looks good but I'm seeing a bug when querying a non-standard level name:

image

(DB: grafana logging dev, service: grafana/grafana or cortex-gw)

matyax commented 2 weeks ago

Yeah. Not really a bug. I'm not sure if we should do nothing when "logs" level is queried or what else. ("logs" level means no known level).

gtk-grafana commented 2 weeks ago

To the user it is a bug, I would expect to see logs that don't have a level. Looks like this is an issue in explore as well

matyax commented 2 weeks ago

Agree. What I mean is that there's nothing broken, just "logs" isn't a level.

gtk-grafana commented 2 weeks ago

Another issue: when selecting multiple, or excluding via holding down command and clicking on a legend item the client-side filtering in the time series panel doesn't match the query behavior. Seeing same behavior in https://github.com/grafana/explore-logs/pull/474

matyax commented 2 weeks ago

When the level is no level/missing level (logs), we can query for level != "" and detected_level != "". We still need to determine if we want to use both or just detected.

when selecting multiple, or excluding via holding down command

Did't know that existed. Will take a look, thanks!

matyax commented 2 weeks ago

It was a small challenge, but I managed to support the panel interactions in both modes (I was about to suggest not supporting append).

https://github.com/grafana/explore-logs/assets/1069378/465ac6f5-bc39-4f81-a757-f6c5358a7b62

I moved the logic to a service that I'd like to reuse for the Logs Volume, should we decide to do the same there.