<?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: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202637#M40093</link>
    <description>&lt;P&gt;Thanks! Fixed it.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 13:47:31 GMT</pubDate>
    <dc:creator>svasani_splunk</dc:creator>
    <dc:date>2017-02-02T13:47:31Z</dc:date>
    <item>
      <title>How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202630#M40086</link>
      <description>&lt;P&gt;I need to get a proper timestamp from raw data that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 0150
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think what I need is the date and the 4 digits at the end. &lt;/P&gt;

&lt;P&gt;I am trying to construct a TIME_FORMAT that gets the date, skips the rest and gets the 4 numbers at the end and puts them in to %H%M &lt;/P&gt;

&lt;P&gt;I have tried a bunch of things but no luck yet. Any help would be appreciated. &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 02:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202630#M40086</guid>
      <dc:creator>tgendron_splunk</dc:creator>
      <dc:date>2016-12-20T02:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202631#M40087</link>
      <description>&lt;P&gt;Try this and see if it works out for you wherein you extract date, hour and min as fields &lt;CODE&gt;myDate, myHr and myMn&lt;/CODE&gt; and then use &lt;CODE&gt;strptime&lt;/CODE&gt; to create &lt;CODE&gt;epoch time&lt;/CODE&gt; stored in &lt;CODE&gt;myEpochTime&lt;/CODE&gt; that can be assigned back to &lt;CODE&gt;_time&lt;/CODE&gt; or used as is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex "Date\sOf\sIncident\:\s*(?&amp;lt;myDate&amp;gt;[\S]+)\s*.*?Time\sof\sIncident\:\s*(?&amp;lt;myHr&amp;gt;\d{2})(?&amp;lt;myMn&amp;gt;\d{2})"
| eval myEpochTime=strptime(myDate." ".myHr.":".myMn, "%m/%d/%Y %H:%M")
| eval _time=myEpochTime
| table _time, myEpochTime, myDate,  myHr,  myMn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/9z0O3Q/1"&gt;See extraction here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 03:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202631#M40087</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-20T03:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202632#M40088</link>
      <description>&lt;P&gt;Thanks for the above. While I am sure the search would do what you explain, my time_stamping  of events during input is still not right. &lt;/P&gt;

&lt;P&gt;I need a TIME_FORMAT technique that will get the correct date and time from the raw data. &lt;BR /&gt;
I get partial success with these lines in a props.conf file. &lt;/P&gt;

&lt;P&gt;LINE_BREAKER = ([\r\n]*)(?=Incident\ Number:\s)&lt;BR /&gt;
TIME_PREFIX = Date Of Incident: &lt;BR /&gt;
TIME_FORMAT = %m/%d/Y% %H:%M:%S" Time of Incident: "%H%M&lt;/P&gt;

&lt;H1&gt;TIME_FORMAT =  %H%M&lt;/H1&gt;

&lt;P&gt;MAX_TIMESTAMP_LOOKAHEAD=46&lt;/P&gt;

&lt;P&gt;The above TIME_FORMAT that is active gives me the correct date  but the time part %H:%M:%S is constant. So every event is on the right day but always at the some time. &lt;/P&gt;

&lt;P&gt;If I use commented out TIME_FORMAT  in conjunction with a  I get the correct time by the date is not set from the wrong data. &lt;/P&gt;

&lt;P&gt;Again the raw data looks like this:&lt;/P&gt;

&lt;P&gt;Incident Number: 150126705&lt;BR /&gt;
        Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 0150&lt;/P&gt;

&lt;P&gt;[snip] &lt;/P&gt;

&lt;P&gt;What I need is the date 12/02/2015 and the ending 0150. Those two will get me the correct timestamp. &lt;/P&gt;

&lt;P&gt;I think I need a props.conf solution &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202632#M40088</guid>
      <dc:creator>tgendron_splunk</dc:creator>
      <dc:date>2020-09-29T12:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202633#M40089</link>
      <description>&lt;P&gt;For this you will have to override the default datetime.xml with your own datetime.xml file &lt;/P&gt;

&lt;P&gt;1) Create a new file called datetime.xml in /etc/apps/search/local/ and add this to your file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;datetime&amp;gt;
&amp;lt;define name="_datetimeformat1" extract="month, day, year, hour, minute"&amp;gt;
    &amp;lt;text&amp;gt;Date Of Incident\:\s(\d{2})\/(\d{2})\/(\d{4})\s\d{1,2}:\d{2}:\d{2}\s[A-Z]{2},\s[^\d]*(\d{2})(\d{2})&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;
&amp;lt;timePatterns&amp;gt;
    &amp;lt;use name="_datetimeformat1"/&amp;gt;
&amp;lt;/timePatterns&amp;gt;
&amp;lt;datePatterns&amp;gt;
    &amp;lt;use name="_datetimeformat1"/&amp;gt;
&amp;lt;/datePatterns&amp;gt;
&amp;lt;/datetime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) Add this in your props.conf&lt;BR /&gt;
DATETIME_CONFIG =  /etc/apps/search/local/datetime.xml&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:59:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202633#M40089</guid>
      <dc:creator>svasani_splunk</dc:creator>
      <dc:date>2017-01-12T16:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202634#M40090</link>
      <description>&lt;P&gt;if anyone wants to use the above answer just need to add &lt;CODE&gt;&amp;lt;/datetime&amp;gt;&lt;/CODE&gt; at the end of datetime.xml file&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 08:59:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202634#M40090</guid>
      <dc:creator>ramighebral</dc:creator>
      <dc:date>2017-01-26T08:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202635#M40091</link>
      <description>&lt;P&gt;Thanks for all of the approaches that have been shared on this question of mine. &lt;/P&gt;

&lt;P&gt;It turns out that I was able to get what I needed with this approach:&lt;/P&gt;

&lt;P&gt;in props.conf  I used the following:&lt;/P&gt;

&lt;P&gt;TIME_PREFIX = Date Of Incident:&lt;BR /&gt;
TIME_FORMAT = %m/%d/%Y 12:00:00 AM, Time of Incident: %H%M&lt;/P&gt;

&lt;P&gt;This gave me a timestamp with the correct date and the time in 24 hour and minutes. &lt;/P&gt;

&lt;P&gt;This was my original approach but I had trouble getting it to work due to typos that took a long time to see them. &lt;BR /&gt;
In the end just  simple strptime() was the machinery needed. &lt;/P&gt;

&lt;P&gt;,&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202635#M40091</guid>
      <dc:creator>tgendron_splunk</dc:creator>
      <dc:date>2020-09-29T12:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202636#M40092</link>
      <description>&lt;P&gt;If your problem is solved, please accept an answer.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 15:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202636#M40092</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-01-26T15:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to construct a TIME_FORMAT that will extract the date and military time when it is separated on the same line?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202637#M40093</link>
      <description>&lt;P&gt;Thanks! Fixed it.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 13:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-construct-a-TIME-FORMAT-that-will-extract-the-date-and/m-p/202637#M40093</guid>
      <dc:creator>svasani_splunk</dc:creator>
      <dc:date>2017-02-02T13:47:31Z</dc:date>
    </item>
  </channel>
</rss>

