grafana / explore-logs

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

Support unpack detection #675

Open GFriedrich opened 2 months ago

GFriedrich commented 2 months ago

It would be great if the explorer could detect whether an unpack call is needed to show the log data properly.

gtk-grafana commented 2 months ago

@GFriedrich can you provide an examples or expected behavior of this proposed feature? I'm not sure I understand the request.

GFriedrich commented 2 months ago

Hi @gtk-grafana, it is my fault - I've used the wrong keyword here. It should read unpack not unwrap. Sorry for the confusion. Right now I've a setup which calls pack when ingesting the data to Loki. And it would be nice if the UI could automatically detect if the data is "packed" and extend the query by a | unpack stage, so all log lines in the UI show correctly.

gtk-grafana commented 2 months ago

@trevorwhitney do you know if there's anyway to detect that a query has been packed at ingest?

GFriedrich commented 2 months ago

@gtk-grafana not sure if it helps, but Grafana simply checks for the existence of the _entry property in the JSON blob:

https://github.com/grafana/grafana/blob/2f012860344d08029e7ad9ce86f7ec79ceee93ec/public/app/plugins/datasource/loki/lineParser.ts#L24

trevorwhitney commented 2 months ago

Yeah, I think looking for _entry is our best bet, though it raises an interesting question. Maybe adding a key to structured metadata would be useful here?