<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there a way to use search time duration in search itself? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151810#M42519</link>
    <description>&lt;P&gt;You can append this to your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addinfo | eval search_time_duration = info_max_time - info_min_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and do your maths after that.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jul 2014 04:25:12 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-07-22T04:25:12Z</dc:date>
    <item>
      <title>Is there a way to use search time duration in search itself?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151809#M42518</link>
      <description>&lt;P&gt;I have a search that use &lt;EM&gt;transaction&lt;/EM&gt; 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. &lt;/P&gt;

&lt;P&gt;Is there a way to find out what was time duration selected for a particular search so it can be used in eval function ? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= public60 eventtype=alarm_notify | rex field=_raw "severity&amp;gt;(?&amp;lt;severity&amp;gt;.*)&amp;lt;/severity.*kpiname&amp;gt;(?&amp;lt;kpi&amp;gt;.*) Bandwidth.*&amp;lt;/kpiname.*target&amp;gt;(?&amp;lt;interface&amp;gt;.*)&amp;lt;/target.*targetparent&amp;gt;(?&amp;lt;device&amp;gt;.*)&amp;lt;/target.*Bandwidth in over (?&amp;lt;bandwidth&amp;gt;.*%) "   | search kpi = wanIf OR lanIf  | eval device_interface = device." - ".interface | transaction startswith=critical endswith=normal | eval available_percentage = (86400-duration)/86400*100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jul 2014 03:44:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151809#M42518</guid>
      <dc:creator>irfans</dc:creator>
      <dc:date>2014-07-22T03:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use search time duration in search itself?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151810#M42519</link>
      <description>&lt;P&gt;You can append this to your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addinfo | eval search_time_duration = info_max_time - info_min_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and do your maths after that.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 04:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151810#M42519</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-22T04:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use search time duration in search itself?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151811#M42520</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 19:39:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151811#M42520</guid>
      <dc:creator>irfans</dc:creator>
      <dc:date>2014-07-22T19:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use search time duration in search itself?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151812#M42521</link>
      <description>&lt;P&gt;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:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | stats earliest(_time) as earliesttime latest(_time) as latesttime | addinfo | foreach *time [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = strftime(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, "%F %G")]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's what I get as a result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;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
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jul 2014 09:39:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-search-time-duration-in-search-itself/m-p/151812#M42521</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-23T09:39:15Z</dc:date>
    </item>
  </channel>
</rss>

