Splunk Search

How to timechart the time differences between (ITNM) events / phases?

meleschi
Explorer

I have the following data that I'm trying to timechart the differences between:

2023-02-16T16:14:04: Data Processing Phase -1 completed
2023-02-16T14:01:00: Data Processing Phase -1 starting
2023-02-16T14:01:00: Data Collection Phase 3 (Final Collection Phase) completed
2023-02-16T11:34:10: Data Collection Phase 2 starting
2023-02-16T11:34:10: Data Collection Phase 1 completed
2023-02-16T11:34:10: Data Collection Phase 3 (Final Collection Phase) starting
2023-02-16T11:34:10: Data Collection Phase 2 completed
2023-02-16T09:01:36: Data Collection Phase 1 starting

 

I've sliced up the data using the following SPL, but that will only give me a look at the time differences over the selected timeline.  I can't figure out how to slice this data up so that I'm able to timechart the differences over multiple runs of the Data Collection Phases.

| stats first(_time) as End, last(_time) as Start by Phase, PhaseIdentifier
| eval RunTime = round((End - Start) / 60, 0)
| eval Start=strftime(Start, "%c")
| eval End=strftime(End, "%c")
| rename RunTime AS "RunTime (Minutes)"

 

I'm used to working more with metrics and logs that spit out runtimes, so this has been vexing me for entirely too long...

Labels (2)
Tags (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

You could use streamstats to define an identifier for each iteration. If, for example, the cycle is terminated by the Data Processing Phase -1 completed, then you can use streamstats to define the iteration count based on that occurring, e.g. this example

| makeresults 
| eval data=split(replace("
2023-02-16T16:14:04: Data Processing Phase -1 completed
2023-02-16T14:01:00: Data Processing Phase -1 starting
2023-02-16T14:01:00: Data Collection Phase 3 (Final Collection Phase) completed
2023-02-16T11:34:10: Data Collection Phase 2 starting
2023-02-16T11:34:10: Data Collection Phase 1 completed
2023-02-16T11:34:10: Data Collection Phase 3 (Final Collection Phase) starting
2023-02-16T11:34:10: Data Collection Phase 2 completed
2023-02-16T09:01:36: Data Collection Phase 1 starting
2023-02-15T16:14:04: Data Processing Phase -1 completed
2023-02-15T14:01:00: Data Processing Phase -1 starting
2023-02-15T14:01:00: Data Collection Phase 3 (Final Collection Phase) completed
2023-02-15T11:34:10: Data Collection Phase 2 starting
2023-02-15T11:34:10: Data Collection Phase 1 completed
2023-02-15T11:34:10: Data Collection Phase 3 (Final Collection Phase) starting
2023-02-15T11:34:10: Data Collection Phase 2 completed
2023-02-15T09:01:36: Data Collection Phase 1 starting", "\n", "##"), "##")
| mvexpand data
| eval _time=strptime(data, "%FT%T")
| rex field=data ": (?<Phase>Data (Processing|Collection) Phase) (?<PhaseIdentifier>-?\d+) (?<state>.*)"
| streamstats count(eval(if(PhaseIdentifier=-1 AND state="completed", 1, null()))) as iteration
| stats first(_time) as End, last(_time) as Start by iteration Phase PhaseIdentifier 
| eval RunTime = round((End - Start) / 60, 0)
| eval Start=strftime(Start, "%c")
| eval End=strftime(End, "%c")
| rename RunTime AS "RunTime (Minutes)"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...