Splunk Search

Splunk Query to form a table with multiple JSON fields

shashaikhhh
Explorer

Below is my splunk raw event data

{
"additional": {
"method": "POST",
"url": "/api/resource/getContentEditorData",
"headers": {
"cloudfront-viewer-country": "US",
"origin": "https://www.site1.com",
"sec-ch-ua-platform": "\"Android\"",
}
},
"level": "notice",
"message": "INCOMING REQUEST: POST /api/resource/getContentEditorData"
}

I need count of cloudfront-viewer-country and sec-ch-ua-platform for each Origin

Please help.

Expected Result:

OriginPlatformPlatform CountCountryCountry Count
https://www.site1.comAndroid10US22
 macOS12UK3
 Windows6AU1
https://www.site2.comAndroid4US8
 macOS4UK1
 Windows2AU1
     
Labels (3)
Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please clarify your requirement.

What if site1 had only 2 countries, or site2 had an extra platform, what would your expected / desired result look like then?

Btw, your JSON example isn't valid JSON (there is a spurious comma after Android.

shashaikhhh
Explorer

If site1 has only 2 countries and site2 has one extra platform, then the expected result should be like below.

OriginPlatformPlatform CountCountryCountry Count
https://www.site1.comAndroid10US22
 macOS12UK3
 Windows6  
https://www.site2.comAndroid4US8
 macOS4UK1
 Windows2AU1
   IND5
0 Karma

shashaikhhh
Explorer

If site1 has only 2 countries, then we need to display 2 records.


Updated Splunk event data:
{
"additional": {
"method": "POST",
"url": "/api/resource/getContentEditorData",
"headers": {
"cloudfront-viewer-country": "US",
"origin": "https://www.site1.com",
"sec-ch-ua-platform": "\"Android\""
}
},
"level": "notice",
"message": "INCOMING REQUEST: POST /api/resource/getContentEditorData"
}

============

{
"additional": {
"method": "POST",
"url": "/api/resource/getContentEditorData",
"headers": {
"cloudfront-viewer-country": "UK",
"origin": "https://www.site1.com",
"sec-ch-ua-platform": "\"Windows\""
}
},
"level": "notice",
"message": "INCOMING REQUEST: POST /api/resource/getContentEditorData"
}

=========================

{
"additional": {
"method": "POST",
"url": "/api/resource/getContentEditorData",
"headers": {
"cloudfront-viewer-country": "AU",
"origin": "https://www.site2.com",
"sec-ch-ua-platform": "\"Windows\""
}
},
"level": "notice",
"message": "INCOMING REQUEST: POST /api/resource/getContentEditorData"
}

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...