Splunk Search

Comparing value from two objects based on another field

oleg1
Loves-to-Learn

Hi Splunk experts, 

My events have a timeline that tells me how long certain operations took. What I'm trying to determine is how frequently "item_B" has a longer duration than "item_C". The array is not guaranteed to have the same order every time so I need to access each object in the array by the "label" field.

Any suggestions?

 

 

timeline":[
   {
      "label":"item_A",
      "duration":1
   },
   {
      "label":"item_B",
      "duration":955,
   },
   {
      "label":"item_C",
      "duration":0,
   },
   {
      "label":"item_D",
      "duration":55,
   }
]

 

 

 

Labels (3)
0 Karma

to4kawa
Ultra Champion
index=_internal | head 1 | fields _raw 
| eval _raw="{\"timeline\":[{\"label\":\"item_A\",\"duration\":1},{\"label\":\"item_B\",\"duration\":955},{\"label\":\"item_C\",\"duration\":0},{\"label\":\"item_D\",\"duration\":55}]}"
| spath timeline{} output=timeline
| mvexpand timeline
| spath input=timeline
| table label duration

please do the math on the rest.

0 Karma
Get Updates on the Splunk Community!

Enhance Your Splunk App Development: New Tools & Support

UCC FrameworkAdd-on Builder has been around for quite some time. It helps build Splunk apps faster, but it ...

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...