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!

Federated Search for Amazon S3 | Key Use Cases to Streamline Compliance Workflows

Modern business operations are supported by data compliance. As regulations evolve, organizations must ...

New Dates, New City: Save the Date for .conf25!

Wake up, babe! New .conf25 dates AND location just dropped!! That's right, this year, .conf25 is taking place ...

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...