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
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...