Splunk Search

How to extract fields from a JSON file from Google Analytics API?

satkumvnr
New Member

Hi dear Splunkers

I have the following JSON given by a REST calling at Google Analytics:

{"kind":"analytics#realtimeData","id":"https://www.googleapis.com/analytics/v3/data/realtime?ids=ga:XXXXXXX&dimensions=rt:eventCategory,rt:eventAction,rt:eventLabel&metrics=rt:totalEvents&filters=rt:eventCategory%3D%3Ddata","query":{"ids":"ga:XXXXXXX","dimensions":"rt:eventCategory,rt:eventAction,rt:eventLabel","metrics":["rt:totalEvents"],"filters":"rt:eventCategory==Results”,”max-results":1000},"totalResults":7,"selfLink":"https://www.googleapis.com/analytics/v3/data/realtime?ids=ga:XXXXXXX&dimensions=rt:eventCategory,rt:eventAction,rt:eventLabel&metrics=rt:totalEvents&filters=rt:eventCategory%3D%3Ddata","profileInfo":{"profileId":"XXXXXXX","accountId":"XXXXXXX","webPropertyId":"XXXXXXX","internalWebPropertyId":"XXXXXXX","profileName":"All Web Site Data","tableId":"realtime:XXXXXXX"},"columnHeaders":[{"name":"rt:eventCategory","columnType":"DIMENSION","dataType":"STRING"},{"name":"rt:eventAction","columnType":"DIMENSION","dataType":"STRING"},{"name":"rt:eventLabel","columnType":"DIMENSION","dataType":"STRING"},{"name":"rt:totalEvents","columnType":"METRIC","dataType":"INTEGER"}],"totalsForAllResults":{"rt:totalEvents":"377"},"rows”:[[“Success”,”search","0JIwnotL","67”],[“Failure”,”search","AgxsqvYs","8"],["Failure","search","DQhOXfQs","41"],["Failure","search","I6HTlk5z","68"],["Results","search","TL7dI0UN","60"],["Success","search","XcC3EU45","69"],["Success","search","oBTyH99G","64"]]}

I'm having a hard time trying to use spath so I can break the data I need as follows:

Results    Process   Info               Count
Failure     search     0JIwnotL       67
Success  search      XcC3EU45    69

Can you guys help me?
How can I use spath (or any other tool) to do this to break as a separate event?
Thanks in advance!

0 Karma

poete
Builder

Hello @satkumvnr,

according to JSONLint, the json is not valid.

I understand you had to modify it in order to remove sensitive information, but the result is not valid and I can not work with it.

Can you please check with jsonLint the result of the pruned json and post it back as an answer to this comment?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...