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!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

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

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...