If `json` parse errors, show raw log; otherwise, format the log - how to do this?

Hi thanks for the wonderful product!

Currently I have something like:

{app="myapp"} | json | line_format "{{.tag}} {{.message}}"

However, some log lines are not in json format, while some is in json format. Currently the non-json log lines will have errors and I have to throw away them. However, I hope that If json parse errors, show raw log; otherwise, format the log - how to do this?

1 Like