Splunk Search

Is there a way to use search time duration in search itself?

irfans
Explorer

I have a search that use transaction command and calculate duration of a transaction , I want to perform calculation on this duration data to find out number of minutes missed due to service outage.

Is there a way to find out what was time duration selected for a particular search so it can be used in eval function ?

index= public60 eventtype=alarm_notify | rex field=_raw "severity>(?<severity>.*)</severity.*kpiname>(?<kpi>.*) Bandwidth.*</kpiname.*target>(?<interface>.*)</target.*targetparent>(?<device>.*)</target.*Bandwidth in over (?<bandwidth>.*%) "   | search kpi = wanIf OR lanIf  | eval device_interface = device." - ".interface | transaction startswith=critical endswith=normal | eval available_percentage = (86400-duration)/86400*100
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You can append this to your search

... | addinfo | eval search_time_duration = info_max_time - info_min_time

and do your maths after that.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You can append this to your search

... | addinfo | eval search_time_duration = info_max_time - info_min_time

and do your maths after that.

martin_mueller
SplunkTrust
SplunkTrust

Not really, you do get the correct time range bounds. For example, when I run this over "Previous month" I expect to have my earliest event around 30 days ago, so the start of the time range is going to be much earlier:

index=_internal | stats earliest(_time) as earliesttime latest(_time) as latesttime | addinfo | foreach *time [eval <<FIELD>> = strftime(<<FIELD>>, "%F %G")]

Here's what I get as a result:

earliesttime         latesttime           info_max_time        info_min_time
2014-06-24 09:08:10  2014-06-30 15:49:01  2014-07-01 00:00:00  2014-06-01 00:00:00
0 Karma

irfans
Explorer

Thanks for quick response, one interesting to note is that duration is never a perfect time period . It seems like instead of search time frame what you end up getting is time difference between earliest and latest search result.

0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...