<?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: extracting timestamp from log with one date and multiple time fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58299#M11453</link>
    <description>&lt;P&gt;Did't notice the field order - modified above to correct.&lt;/P&gt;</description>
    <pubDate>Sat, 25 Sep 2010 05:14:46 GMT</pubDate>
    <dc:creator>southeringtonp</dc:creator>
    <dc:date>2010-09-25T05:14:46Z</dc:date>
    <item>
      <title>extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58293#M11447</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am unable to extract a valid _time from the following log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0168 004 07:59:03 09:01:35 0062 asdfghj ee bonfanyti Y                                             P1233443P       443386 0012 07:59:17    dial_in  1                                  1234 N N                                                       34567654555 000523456778 0000 09/20/10  0                                                                                                                                                                                                 1624443                                          01
0344 003 07:58:33 09:01:36 0063 Ssdfas Fd asdfffftim Y                                             P5243343P       455483 0032 07:58:48    dial_in  1                                  7950 N N                                                                   000234234218 0000 09/20/10  0                                                                                                                                                                                                 1624443                                          01
0433 007 08:00:14 09:01:36 0061 ewrwreerer asdfsdfff N                                             P5243443P       451333 0061 08:00:30    dial_in 19                                  7952 N N                                                       58916588270 000522349181 0000 09/20/10  0                                                                                                                                                                                                 5673443                                          01
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;timestamps I would like to extract are:&lt;/P&gt;

&lt;P&gt;1) 09/20/10 07:59:03 &lt;/P&gt;

&lt;P&gt;2) 09/20/10 07:58:33&lt;/P&gt;

&lt;P&gt;3) 09/20/10 08:00:14&lt;/P&gt;

&lt;P&gt;Reading the documentation I have figured out that I can only extract it using a custom datetime.xml&lt;/P&gt;

&lt;P&gt;I have tried to construct a datatime.xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;datetime&amp;gt;
&amp;lt;define name="ccm_1_date" extract="month,day,year,"&amp;gt;
    &amp;lt;text&amp;gt;&amp;lt;![CDATA[\s+\d+\s(\d+)/(\d+)/(\d+)]]&amp;gt;&amp;lt;/text&amp;gt;
  &amp;lt;/define&amp;gt;
  &amp;lt;define name="ccm_1_time" extract="second,minute,hour,"&amp;gt;
    &amp;lt;text&amp;gt;&amp;lt;![CDATA[\s\d+:\d+:\d+\s]]&amp;gt;&amp;lt;/text&amp;gt;
  &amp;lt;/define&amp;gt;

  &amp;lt;timePatterns&amp;gt;
    &amp;lt;use name="ccm_1_time"/&amp;gt;
  &amp;lt;/timePatterns&amp;gt;
  &amp;lt;datePatterns&amp;gt;
    &amp;lt;use name="ccm_1_date"/&amp;gt;
  &amp;lt;/datePatterns&amp;gt;

&amp;lt;/datetime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The date pattern is probably good, but the time pattern is suspicious.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;props.conf:


[host::ccm]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;SHOULD_LINEMERGE = false&lt;/P&gt;

&lt;P&gt;DATETIME_CONFIG = /etc/apps/search/local/datetime.xml&lt;/P&gt;

&lt;P&gt;MAX_TIMESTAMP_LOOKAHEAD = 300&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 03:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58293#M11447</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2010-09-25T03:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58294#M11448</link>
      <description>&lt;P&gt;Your regex in ccm_1_time does not capture any groups.&lt;/P&gt;

&lt;P&gt;Try adding parentheses to capture each value, and make sure that the timestamp regex only matches the first set of colon-delimited digits...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;datetime&amp;gt;
    &amp;lt;define name="ccm_1_date" extract="day,month,year,"&amp;gt;
        &amp;lt;text&amp;gt;&amp;lt;![CDATA[\s+\d+\s(\d+)/(\d+)/(\d+)]]&amp;gt;&amp;lt;/text&amp;gt;
    &amp;lt;/define&amp;gt;
    &amp;lt;define name="ccm_1_time" extract="hour,minute,second,"&amp;gt;
        &amp;lt;text&amp;gt;&amp;lt;![CDATA[^(?:\d+\s)+(\d+):(\d+):(\d+)\s]]&amp;gt;&amp;lt;/text&amp;gt;
    &amp;lt;/define&amp;gt;

    &amp;lt;timePatterns&amp;gt;
        &amp;lt;use name="ccm_1_time"/&amp;gt;
    &amp;lt;/timePatterns&amp;gt;
    &amp;lt;datePatterns&amp;gt;
        &amp;lt;use name="ccm_1_date"/&amp;gt;
    &amp;lt;/datePatterns&amp;gt;
&amp;lt;/datetime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Sep 2010 03:56:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58294#M11448</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-09-25T03:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58295#M11449</link>
      <description>&lt;P&gt;No, it does not. Every event has the same _time field :&lt;BR /&gt;
9/23/10 9:50:47.000 PM&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 04:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58295#M11449</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2010-09-25T04:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58296#M11450</link>
      <description>&lt;P&gt;9/23/10 9:50:47.000 PM is the time of last modificaton of the log file. Why is it used instead of the intended fields?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 04:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58296#M11450</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2010-09-25T04:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58297#M11451</link>
      <description>&lt;P&gt;because if Splunk fails to get a date or time from the data, it next tries the file/source name, and then the mod time of the file. &lt;A href="http://www.splunk.com/base/Documentation/latest/Admin/HowSplunkextractstimestamps#Precedence_rules_for_timestamp_assignment"&gt;http://www.splunk.com/base/Documentation/latest/Admin/HowSplunkextractstimestamps#Precedence_rules_for_timestamp_assignment&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 04:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58297#M11451</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-09-25T04:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58298#M11452</link>
      <description>&lt;P&gt;also, the &lt;CODE&gt;extract&lt;/CODE&gt; must be in order of the capture groups. use &lt;CODE&gt;hour, minute, second&lt;/CODE&gt; instead of &lt;CODE&gt;second, minute, hour&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 04:57:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58298#M11452</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-09-25T04:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58299#M11453</link>
      <description>&lt;P&gt;Did't notice the field order - modified above to correct.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 05:14:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58299#M11453</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-09-25T05:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58300#M11454</link>
      <description>&lt;P&gt;modified accordingly, _time is again  9/23/10 9:50:47.000 PM&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 05:33:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58300#M11454</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2010-09-25T05:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58301#M11455</link>
      <description>&lt;P&gt;found a typo, the correct time line is :&lt;BR /&gt;
&lt;TEXT&gt;&amp;lt;![CDATA[^(?:\d+\s)+(\d+):(\d+):(\d+)\s]]&amp;gt;&lt;/TEXT&gt;&lt;/P&gt;

&lt;P&gt;Now the time part is correctly recognised, date part is still not working as it should. What could be the problem with:&lt;/P&gt;

&lt;P&gt;&lt;DEFINE name="ccm_1_date" extract="month,day,year,"&gt;&lt;BR /&gt;
        &lt;TEXT&gt;&amp;lt;![CDATA[\s+\d+\s(\d+)/(\d+)/(\d+)]]&amp;gt;&lt;/TEXT&gt;&lt;/DEFINE&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2010 05:43:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58301#M11455</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2010-09-25T05:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58302#M11456</link>
      <description>&lt;P&gt;The order is still wrong; it would need to be "day,month,year,". The regex looks like it should match, but in your sample data the second part is 20, which isn't a valid month.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2010 22:19:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58302#M11456</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-09-26T22:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: extracting timestamp from log with one date and multiple time fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58303#M11457</link>
      <description>&lt;P&gt;Try the following datetime.xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;datetime&amp;gt;
    &amp;lt;define name="ccm_1_date" extract="month,day,year"&amp;gt;
        &amp;lt;text&amp;gt;&amp;lt;![CDATA[0000\s(\d{2})/(\d{2})/(\d{2})]]&amp;gt;&amp;lt;/text&amp;gt;
    &amp;lt;/define&amp;gt;
    &amp;lt;define name="ccm_1_time" extract="hour,minute,second"&amp;gt;
        &amp;lt;text&amp;gt;&amp;lt;![CDATA[\*\*\*\s(\d{2}):(\d{2}):(\d{2})]]&amp;gt;&amp;lt;/text&amp;gt;
    &amp;lt;/define&amp;gt;
    &amp;lt;define name="ccm_2_time" extract="hour,minute,second"&amp;gt;
        &amp;lt;text&amp;gt;&amp;lt;![CDATA[\d{3}s(\d{2}):(\d{2}):(\d{2})]]&amp;gt;&amp;lt;/text&amp;gt;
    &amp;lt;/define&amp;gt;
    &amp;lt;timePatterns&amp;gt;
      &amp;lt;use name="ccm_1_time"/&amp;gt; 
      &amp;lt;use name="ccm_2_time"/&amp;gt;
    &amp;lt;/timePatterns&amp;gt;
    &amp;lt;datePatterns&amp;gt;
      &amp;lt;use name="ccm_1_date"/&amp;gt; 
    &amp;lt;/datePatterns&amp;gt;
&amp;lt;/datetime&amp;gt;      
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I don't recommend updating the default datetime.xml.  During upgrade your configuration will be overwritten.  Name it something like datetime2.xml and specify this in your props.conf with DATETIME_CONF.  ie:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extracttime]
SHOULD_LINEMERGE = false
DATETIME_CONF=\etc\garfield.xml
MAX_TIMESTAMP_LOOKAHEAD = 1000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Sep 2010 02:25:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extracting-timestamp-from-log-with-one-date-and-multiple-time/m-p/58303#M11457</guid>
      <dc:creator>elusive</dc:creator>
      <dc:date>2010-09-28T02:25:00Z</dc:date>
    </item>
  </channel>
</rss>

