<?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: Eval Diff in Time Format issues in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168429#M48032</link>
    <description>&lt;P&gt;oops... just realized that this question was rather old. Well, hope that you solved your problem already, or if you didn't - that this helped a bit... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
    <pubDate>Tue, 25 Mar 2014 01:17:44 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2014-03-25T01:17:44Z</dc:date>
    <item>
      <title>Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168426#M48029</link>
      <description>&lt;P&gt;I have firewall logs like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Dec  5 14:43:14 SF3D-DC SF: [1:12345:1] "Event Name" [Impact: Currently Not Vulnerable] From "My.Server.local" at Thu Dec  5 14:43:08 2013 UTC&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;the first time 14:43:14 in the string is the writeTime that the event was put in the IDS database.&lt;/P&gt;

&lt;P&gt;The second time 14:43:08 is the eventTime that is the time that the IDS sensor detected the event.&lt;/P&gt;

&lt;P&gt;I woulds like to do this:&lt;/P&gt;

&lt;P&gt;sourcetype=IDS | eval timeDiff=writeTime - eventTime | stats avg(timeDiff)&lt;/P&gt;

&lt;P&gt;This looks like ti should work but I think I am hanging on the strptime.  since the time is already formated in the extraction should I still need to convert it to time?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2013 18:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168426#M48029</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2013-12-05T18:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168427#M48030</link>
      <description>&lt;P&gt;The field extraction is making writeTime and eventTime as string, so a "-" operation will not work directly. You need to convert it to epoch time for such calculations.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2013 19:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168427#M48030</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-05T19:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168428#M48031</link>
      <description>&lt;P&gt;To expand on the explanation given by somesoni2 (assuming that the first timestamp (writeTime) is extracted into the &lt;CODE&gt;_time&lt;/CODE&gt; field, i.e. the splunk timestamp for the event);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=IDS | rex "at\s(?&amp;lt;eventTime&amp;gt;(\S+\s){5}\S+)$" | eval eventTime = strptime(eventTime, "%a %b %e %H:%M:%S %Y %Z") | eval timeDiff = _time - eventTime | stats avg(timeDiff) as avg_diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you the average &lt;CODE&gt;timeDiff&lt;/CODE&gt; in seconds (avg_diff = 6). If you want to you make &lt;CODE&gt;avg_diff&lt;/CODE&gt; "look nicer", you add this to the end;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval avg_diff = tostring(avg_diff, "duration") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, avg_diff = 00:00:06&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:13:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168428#M48031</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2020-09-28T16:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168429#M48032</link>
      <description>&lt;P&gt;oops... just realized that this question was rather old. Well, hope that you solved your problem already, or if you didn't - that this helped a bit... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2014 01:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168429#M48032</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-03-25T01:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168430#M48033</link>
      <description>&lt;P&gt;Kristian,  thanks so much this was the answer but if I could ask you one thing.  I have extracts for the time's in the data so this is my search.&lt;BR /&gt;
&lt;CODE&gt;sourcetype=IDS | eval eventTime = strptime(eventTime, "%H:%M:%S") | eval writeTime = strptime(writeTime, "%H:%M:%S") | eval timeDiff = writeTime - eventTime | stats avg(timeDiff) as avg_diff | eval avg_diff = tostring(avg_diff, "duration")&lt;/CODE&gt;&lt;BR /&gt;
My question is [I can't seem to use (timechart span=15m) in place of stats?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2014 12:42:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168430#M48033</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2014-03-25T12:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168431#M48034</link>
      <description>&lt;P&gt;Timechart converts values into columns hence the eval avg_diff will not work (not column name present with that name). Your can try this workaround for it.&lt;/P&gt;

&lt;P&gt;sourcetype=IDS | eval eventTime = strptime(eventTime, "%H:%M:%S") | eval writeTime = strptime(writeTime, "%H:%M:%S") | eval timeDiff = writeTime - eventTime | bucket _time span=15m | stats avg(timeDiff) as avg_diff by _time| eval avg_diff = tostring(avg_diff, "duration") | timechart span=15m first(avg_diff) as avg_diff&lt;/P&gt;

&lt;P&gt;Since the value of avg_diff will be string, you won't be able to see any chart visualization but will work for table.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168431#M48034</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T16:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Diff in Time Format issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168432#M48035</link>
      <description>&lt;P&gt;Thanks this will work.&lt;/P&gt;

&lt;P&gt;I ended up using the numerical value to get the chart like this&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=IDS | eval eventTime = strptime(eventTime, "%H:%M:%S") | eval writeTime = strptime(writeTime, "%H:%M:%S") | eval timeDiff = writeTime - eventTime | timechart span=15m avg(timeDiff) as avg_diff&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I can use this to see trends and set alert values&lt;/P&gt;

&lt;P&gt;Thanks again for your help&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2014 17:57:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Diff-in-Time-Format-issues/m-p/168432#M48035</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2014-03-25T17:57:00Z</dc:date>
    </item>
  </channel>
</rss>

