Hi, I'm trying to figure out how to extract fields...
# support
j
Hi, I'm trying to figure out how to extract fields from log messages. The messages are emitted as json lines and picked up, and when I look in the signoz ui at the json for an entry, the
body
field is a string. I assume that means I have to use a
json_parser
to get the structured data out of it, but no matter what I do it doesn't seem to actually parse it, so does anybody know what might be wrong? There are no errors in the collector log...
I tried adding this to the operators:
Copy code
- type: json_parser
          if: 'body startsWith "{"'
          parse_from: body
          parse_to: attributes.body
But no
attributes.body
field appears anywhere
v
@nitya-signoz can help here
n
Yeah you will have to use json parser, based on your log line you migh have to use a regex parse if there are non json elements in your log line ex:- https://github.com/SigNoz/logs-benchmark/blob/0b2451e6108d8fa5fdd5808c4e174bd52b9d55d3/signoz/signoz-client/otel-collector-config.yaml#L9