Getting Data In

How to parse array to get only required attribute?

Techie
Engager

Hello,

I have an array of timeline event.

Timeline[ [-]
       { [-]
         deltaToStart788
         startTime2023-02-01T21:56:11Z
         typeservice1
       }
       { [-]
         deltaToStart653
         startTime2023-02-01T21:56:11.135Z
         typeservice2
       }

     ]

I would like to table deltaToStart value only of type service1. 

 

Thanks.

Labels (1)
0 Karma

Techie
Engager

@ITWhisperer , thanks for responding.  Can you also help me to calculate sum of both durations and table all 3 fields (message.duration, deltaToStart, total_time)

total_time = message.duration + deltaToStart (of type service1)

message: { [-]
duration: 182
Timeline: [ [-]
{ [-]
deltaToStart: 788
startTime: 2023-02-01T21:56:11Z
type: service1
}
{ [-]
deltaToStart: 653
startTime: 2023-02-01T21:56:11.135Z
type: service2
}
]
}

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What have you tried so far?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| spath Timeline{} output=Timeline
| mvexpand Timeline
| spath input=Timeline
| where type="service1"
| table deltaToStart
0 Karma
Get Updates on the Splunk Community!

New Year. New Skills. New Course Releases from Splunk Education

A new year often inspires reflection—and reinvention. Whether your goals include strengthening your security ...

Splunk and TLS: It doesn't have to be too hard

Overview Creating a TLS cert for Splunk usage is pretty much standard openssl.  To make life better, use an ...

Faster Insights with AI, Streamlined Cloud-Native Operations, and More New Lantern ...

Splunk Lantern is a Splunk customer success center that provides practical guidance from Splunk experts on key ...