Getting Data In

JSON Split at Index Time

krishnakesiraju
Explorer

Hi all,

I have a JSON file output from a RESTful API service and the log looks something like this:

{
"Provider": "Provider1",
"AccountId": "Account1",
"Status": "NON_COMPLIANT",
"AggregatedStatus": {
"Control1": "COMPLIANT",
"Control2": "NON_COMPLIANT",
"Control3": "COMPLIANT"
},
"ResourceCounter": 3,
"DetailedResult": [
{
"RuleName": "Rule1",
"ResourceID": "ID65329083",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control1",
"SubCategory": "SubCat1"
},
{
"RuleName": "Rule2",
"ResourceID": "ID234ti4",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control2",
"SubCategory": "SubCat2"
},
{
"RuleName": "Rule3",
"ResourceID": "ID7523427",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control3",
"SubCategory": "SubCat3"
}
]
}

Is it possible to split the JSON into multiple events and filter/index the output based on "Category": "Control2". Ideally, I would like to view the broken down events like this and may be filter events based on the "Category" field. Is this even possible?

{
"Provider": "Provider1",
"AccountId": "Account1",
"Status": "NON_COMPLIANT",
"AggregatedStatus": {
"Control1": "COMPLIANT"
},
"ResourceCounter": 1,
"DetailedResult": [
{
"RuleName": "Rule1",
"ResourceID": "ID65329083",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control1",
"SubCategory": "SubCat1"
}
]

}

{
"Provider": "Provider1",
"AccountId": "Account1",
"Status": "NON_COMPLIANT",
"AggregatedStatus": {
"Control2": "NON_COMPLIANT"
},
"ResourceCounter": 1,
"DetailedResult": [
{
"RuleName": "Rule2",
"ResourceID": "ID234ti4",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control2",
"SubCategory": "SubCat2"
}
]
}


{
"Provider": "Provider1",
"AccountId": "Account1",
"Status": "NON_COMPLIANT",
"AggregatedStatus": {
"Control3": "COMPLIANT"
},
"ResourceCounter": 1,
"DetailedResult": [
{
"RuleName": "Rule3",
"ResourceID": "ID7523427",
"ResourceType": "Type1",
"Timestamp": "2019-07-25T06:53:13.030000",
"Status": "NON_COMPLIANT",
"Severity": "medium",
"Category": "Control3",
"SubCategory": "SubCat3"
}
]
}

Thanks,
Krishna

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I think you need to create a scripted input to break the file up like that.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Enhance Security Operations with Automated Threat Analysis in the Splunk EcosystemAre you leveraging ...

Splunk Developers: Go Beyond the Dashboard with These .Conf25 Sessions

  Whether you’re building custom apps, diving into SPL2, or integrating AI and machine learning into your ...

Index This | How do you write 23 only using the number 2?

July 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...