<?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 compare time format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220028#M188070</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
A job needs to be completed by 04:45 AM, &lt;BR /&gt;
Can some one help me to extract time from the logs, compare 04:45 AM and send an alert.&lt;BR /&gt;
Kindly help&lt;/P&gt;</description>
    <pubDate>Sun, 13 Sep 2015 01:30:50 GMT</pubDate>
    <dc:creator>marellasunil</dc:creator>
    <dc:date>2015-09-13T01:30:50Z</dc:date>
    <item>
      <title>compare time format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220028#M188070</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
A job needs to be completed by 04:45 AM, &lt;BR /&gt;
Can some one help me to extract time from the logs, compare 04:45 AM and send an alert.&lt;BR /&gt;
Kindly help&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 01:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220028#M188070</guid>
      <dc:creator>marellasunil</dc:creator>
      <dc:date>2015-09-13T01:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: compare time format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220029#M188071</link>
      <description>&lt;P&gt;It'd help if we knew what the time in your logs looked like.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 02:27:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220029#M188071</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-09-13T02:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: compare time format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220030#M188072</link>
      <description>&lt;P&gt;Hi Martin,&lt;BR /&gt;
Thanks for your reply.&lt;/P&gt;

&lt;P&gt;In the logs, we have OSTIME field. From OSTIME, we need to extract %H:%M. &lt;BR /&gt;
Everyday this value need to compare with 04:45, to check the job is runningeven after 04:45 AM&lt;/P&gt;

&lt;P&gt;The time format in logs looks like below&lt;BR /&gt;
OSTIME="11/09/2015 06:05:00"&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 10:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220030#M188072</guid>
      <dc:creator>marellasunil</dc:creator>
      <dc:date>2015-09-13T10:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: compare time format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220031#M188073</link>
      <description>&lt;P&gt;Mkay... assuming the field &lt;CODE&gt;OSTIME&lt;/CODE&gt; is already extracted, do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=OSTIME "(?&amp;lt;OS_hour&amp;gt;\d+):(?&amp;lt;OS_minute&amp;gt;\d+)" | eval too_late = if(OS_hour * 60 + OS_minute &amp;gt; 285, "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not treating it as a date because you're not interested in the date, or the entire timestamp. You're just looking to compare the &lt;CODE&gt;HH:MM&lt;/CODE&gt; portion to see if more than 285 minutes have elapsed since midnight. An alternative, approach using the entire timestamp would be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval OSTIME_epoch = strptime(OSTIME, "%m/%d/%Y %H:%M:%S") | eval too_late = if((OSTIME_epoch - relative_time(OSTIME_epoch, "@d")) &amp;gt; (285*60), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this may fail when combined with daylight savings changes... more or less time will have elapsed on those two days when it is 04:45.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 10:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-time-format/m-p/220031#M188073</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-09-13T10:59:02Z</dc:date>
    </item>
  </channel>
</rss>

