Promtail parse json without filtering fields

I have JSON logs, they use different ways of indicating the level (level vs. lvl) and also log various extra metadata fields, so not just “message”.

I’d like to parse the json so I can tell Loki what the level is without adding this to the query every time.

I’d like to parse all the fields on each log line. Many contain important information, and more importantly can’t be predicted.

It seems this is currently impossible. If you add a json pipeline which extracts the level, you lose the other fields. When writing a query in Loki however this works just fine, and you can json parse and indicate the what field holds the level for example, without losing all other information.

Can this be done or at least worked around somehow? It’s a real pain to remember for each service how the log should be parsed even if Loki is great at suggestion some things like the level field.

Apparently the output stage doesn’t only change the line you’ll see in Loki it also drops all other data. Remove that stage fixes the above.