grafana / explore-logs

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

Fields: Fields from JSON parse showing on logfmt #638

Closed gtk-grafana closed 3 days ago

gtk-grafana commented 1 month ago

Introduced by https://github.com/grafana/explore-logs/pull/629, Appears to only happen when switching between services that require different log parsers (logfmt and json) using the service selection dropdown. You also have to switch tabs before the new logs query returns.

From json -> logfmt

image

from logfmt -> json

image

A bit of an edge case, but we should be clearing the parser on update of the service. Workaround: refresh the page, wait until queries finish on logs tab before switching to fields.

gtk-grafana commented 1 month ago

I've got a potential fix for this, but it requires adding a new event to scenes when a SceneQueryRunner stream is cancelled.

Basically the problem is that when we switch services, and then quickly navigate to another tab, the original query to fetch the sample of log lines to determine the format is cancelled, and the fields page will just use the prior dataframe to figure out the parser, which is incorrect if you are switching between services that need different parsers.

While subscribing to a cancelled event on the SceneQueryRunner, and manually kicking-off the new queryrunner when the query has been cancelled in another instance of the ServiceScene technically works, ideally we could just not cancel the logs query when switching tabs.

I'll come back to this tomorrow and see if I can come up with a better solution then just restarting the cancelled query that we didn't want to cancel.

gtk-grafana commented 3 days ago

Should be fixed by https://github.com/grafana/explore-logs/pull/736