Splunk Search

Extracting fields from nested JSON event

kmaron
Motivator

I have a very complex nested JSON event and need to extract 2 fields. I've managed it with less complicated ones but this one has be a bit stumped.

I need to get the avgCycles and totalExecutions for each iRule - keeping hold of the name of the iRule. 

My event looks like this:

 

 

{ [-]
   clientSslProfiles: { [+]
   }
   deviceGroups: { [+]
   }
   httpProfiles: { [+]
   }
   iRules: { [-]
     /Department/Shared/Department_HTML_rewrite_Rule: { [-]
       application: Shared
       events: { [-]
         CLIENT_ACCEPTED: { [+]
         }
         HTML_TAG_MATCHED: { [+]
         }
         HTTP_REQUEST: { [+]
         }
         HTTP_RESPONSE: { [-]
           aborts: 0
           avgCycles: 28338
           failures: 0
           maxCycles: 1882653
           minCycles: 8898
           priority: 550
           totalExecutions: 86269
         }
       }
       name: /Department/Shared/Department_HTML_rewrite_Rule
       tenant: Department
     }
     /Common/Office-Rule: { [+]
     }
     /Common/Debug-Rule: { [+]
.....

 

 

 

 

Labels (1)
0 Karma

to4kawa
Ultra Champion

The command cannot be applied firmly because there is no log of _raw, but spath output= should be fine.

0 Karma

kmaron
Motivator

I don't understand what you're saying.   I need to pull out only the avgCycles and totalExecutions for every iRule, attached to the name of the iRule.  but I do not know how many there are, or what they are named. spath is just the start. It doesn't do the extraction or allow me to isolate those fields when I don't know the iRule names. 

0 Karma

to4kawa
Ultra Champion

I can't make a regular expression because you're only presenting the processed log. Also, there are no multiple logs.

0 Karma

to4kawa
Ultra Champion

Why don't you spath and table?

0 Karma

kmaron
Motivator

@to4kawa  I can spath but I have no idea how many iRules there will be per event or what they are named, and I don't know how many event types there will be or what they are named. 

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...