Splunk Search

How to extract fields from json attributes?

sergimola
Explorer

I am sending some traces from my service to Splunk using the OpenTelemetry Collector and the Splunk HEC exporter.

My traces are getting to Splunk and their fields in general properly identified, but I would like for the attributes of an event that have a json format to be further decomposed into fields.

This is an example of an event:

sergimola_0-1676983025324.png

I would like for the `attributes.data` field to be further decomposed.

Is that possible?

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| spath output=data path=attributes.data
| spath input=data

View solution in original post

sergimola
Explorer

I've looked into `spath`, but I think there's something else on top of that.

It works for the event itself wich is a json event, but onf the the properties inside this json event is also a json structure.

sergimola_0-1676988428602.png

 

Using this works fine:

| spath output=data path=attributes.data

But if I want to create a field out of the `Number` property in `attributes.data` that doesn't work

| spath output=data_number path=attributes.data.Number

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| spath output=data path=attributes.data
| spath input=data

sergimola
Explorer

Oh, nice, this works!

Thanks.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use the spath command in your search query to extract fields from JSON events.

---
If this reply helps you, Karma would be appreciated.
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You can use spath in your search SPL to extract fields from JSON data.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...