Getting Data In

JSON is one huge single entry - Is there a way to break it apart in Splunk?

larryleeroberts
Path Finder

Hello. We just installed the REST API Modular Input App into Splunk in order to capture Dynatrace logs from the Dynatrace SaaS environment. The output format from Dynatrace is in JSON. It works good as the Dynatrace data is coming right into Splunk.

The problem is I can not seem to figure out how I can split it apart inside Splunk.
For example, each line item in Splunk should be based on the Dynatrace “logId” rather than one huge single line entry. As you can from the start of the JSON output from Dynatrace, there is actually 70 log entries in this JSON. Each one should be its own entry in Splunk.

Does anyone know if there is something I can do via the REST API Modular Input App configuration (Data Input configuration) that would tell it to split this JSON by the “logId”? If not, is there a way I could tell Splunk to do it?

As you can see, every single log entry is all listed as one huge line item in Splunk.
alt text

Here is what the returned JSON looks like directly in Google Chrome.
alt text

Thank you

0 Karma
1 Solution

to4kawa
Ultra Champion

70lines is OK, mvexpand OR stats list

your search
| spath path=auditLogs{} output=auditLogs
| stats values(_time) as _time by auditLogs

After this, let`s extract fields.

If you are lucky,

your search
| spath path=auditLogs{} output=auditLogs
| stats values(_time) as _time by auditLogs
| spath input=auditLogs

That's all.

View solution in original post

to4kawa
Ultra Champion

70lines is OK, mvexpand OR stats list

your search
| spath path=auditLogs{} output=auditLogs
| stats values(_time) as _time by auditLogs

After this, let`s extract fields.

If you are lucky,

your search
| spath path=auditLogs{} output=auditLogs
| stats values(_time) as _time by auditLogs
| spath input=auditLogs

That's all.

larryleeroberts
Path Finder

That did the trick! So much better. Thank you!
I was hoping there was a way I could do it through configuration, but if through search is the only way, that works too. Very much appreciated.

0 Karma

to4kawa
Ultra Champion

wow, you are lucky.
Thanks and happy Splunking.

0 Karma

Balajiraj
Explorer

Approach 1) Have u tried combination of spath and mv expand. Something like spath path=auditLogs{} output=x | fields - _raw | fields x| mvexpand x
Approach 2) Try delimiting by logId and then assign value to field and apply mvexpand on top of it

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...