<?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 do I configure timestamp extraction where day may be one or two digits in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32507#M5782</link>
    <description>&lt;P&gt;I believe unfortunately that the "%e" opption still winds up with two characters. &lt;BR /&gt;
Though lot of python tutorials do not mention it, when the day number is less than 10 &lt;BR /&gt;
"%e" seems to front pad with a blank, where "%d" frontpads with a zero. &lt;BR /&gt;
As is born out by the folowing ksh and python script content and output.&lt;/P&gt;

&lt;P&gt;#----------------------&lt;/P&gt;

&lt;P&gt;#!/bin/ksh&lt;/P&gt;

&lt;P&gt;# ksh_date_with_d_and_e&lt;BR /&gt;&lt;BR /&gt;
# If current day of the month is greater than 9 then print date time out&lt;BR /&gt;&lt;BR /&gt;
# for the 9th of the month.  Otherwise print out current date time&lt;BR /&gt;&lt;BR /&gt;
#&lt;BR /&gt;&lt;BR /&gt;
DAY=&lt;CODE&gt;date +%e&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
if [ $DAY -gt 9 ]&lt;BR /&gt;&lt;BR /&gt;
then&lt;BR /&gt;&lt;BR /&gt;
     let BACK=$DAY-9&lt;BR /&gt;&lt;BR /&gt;
else&lt;BR /&gt;&lt;BR /&gt;
     BACK=0&lt;BR /&gt;&lt;BR /&gt;
fi&lt;BR /&gt;&lt;BR /&gt;
date -d "$BACK days ago"  +"%y/%d/%m %k:%M:%S"&lt;BR /&gt;&lt;BR /&gt;
date -d "$BACK days ago"  +"%y/%e/%m %k:%M:%S"&lt;BR /&gt;&lt;BR /&gt;
# END  &lt;/P&gt;

&lt;P&gt;SAMPLE OUTPUT:&lt;BR /&gt;&lt;BR /&gt;
11/09/12 10:50:15&lt;BR /&gt;&lt;BR /&gt;
11/ 9/12 10:50:15  &lt;/P&gt;

&lt;P&gt;#----------------------&lt;BR /&gt;&lt;BR /&gt;
#!/usr/bin/python&lt;BR /&gt;&lt;BR /&gt;
# python_date_with_d_and_e"&lt;BR /&gt;&lt;BR /&gt;
# Using hard coded date here&lt;BR /&gt;&lt;BR /&gt;
#&lt;BR /&gt;&lt;BR /&gt;
import time&lt;BR /&gt;&lt;BR /&gt;
t = (2011, 12, 9, 17, 3, 38, 1, 48, 0)&lt;BR /&gt;&lt;BR /&gt;
t = time.mktime(t)&lt;BR /&gt;&lt;BR /&gt;
print time.strftime("%y/%d/%m %k:%M:%S", time.gmtime(t))&lt;BR /&gt;&lt;BR /&gt;
print time.strftime("%y/%e/%m %k:%M:%S", time.gmtime(t))&lt;BR /&gt;&lt;BR /&gt;
# END  &lt;/P&gt;

&lt;P&gt;SAMPLE OUTPUT:&lt;BR /&gt;&lt;BR /&gt;
11/09/12 23:03:38&lt;BR /&gt;&lt;BR /&gt;
11/ 9/12 23:03:38&lt;BR /&gt;&lt;BR /&gt;
#----------------------&lt;BR /&gt;&lt;BR /&gt;
Unless splunk does something special for "%e" different than python or ksh,&lt;BR /&gt;&lt;BR /&gt;
it seems this would still not match for a single character day in date field&lt;BR /&gt;&lt;BR /&gt;
I have not had a chance to experiment further so is still conjecture on my part.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 10:13:45 GMT</pubDate>
    <dc:creator>clmiller</dc:creator>
    <dc:date>2020-09-28T10:13:45Z</dc:date>
    <item>
      <title>How do I configure timestamp extraction where day may be one or two digits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32505#M5780</link>
      <description>&lt;P&gt;I have a timestamp of form &lt;BR /&gt;
[10/15/11 11:55:08:992 PDT] . . . log entry text . . .&lt;BR /&gt;&lt;BR /&gt;
I expect I can try the following specifier in props.conf file for the above Oct 10th 2011 date format:&lt;BR /&gt;
TIME_PREFIX = ^.&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 22&lt;BR /&gt;
TIME_FORMAT = %y/%d/%m %k:%M:%S&lt;BR /&gt;
But for dates where the day of the month of log entry is less than 10 I hve something like:&lt;BR /&gt;
[12/8/11 11:55:08:992 PDT] . . . log entry text . . . &lt;BR /&gt;
My understanding is %d works for a two digit day format, but I don't see a good option when day can be two digits or a single non-padded digit day of month representation.&lt;BR /&gt;
Suggestions? &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:12:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32505#M5780</guid>
      <dc:creator>clmiller</dc:creator>
      <dc:date>2020-09-28T10:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I configure timestamp extraction where day may be one or two digits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32506#M5781</link>
      <description>&lt;P&gt;Hi, not that I've tried it, but &lt;CODE&gt;%e&lt;/CODE&gt; might work for you. &lt;/P&gt;

&lt;P&gt;According to &lt;A href="http://www.tutorialspoint.com/python/time_strftime.htm"&gt;http://www.tutorialspoint.com/python/time_strftime.htm&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;%d - day of the month (01 to 31)
%e - day of the month (1 to 31)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2011 11:44:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32506#M5781</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2011-12-15T11:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I configure timestamp extraction where day may be one or two digits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32507#M5782</link>
      <description>&lt;P&gt;I believe unfortunately that the "%e" opption still winds up with two characters. &lt;BR /&gt;
Though lot of python tutorials do not mention it, when the day number is less than 10 &lt;BR /&gt;
"%e" seems to front pad with a blank, where "%d" frontpads with a zero. &lt;BR /&gt;
As is born out by the folowing ksh and python script content and output.&lt;/P&gt;

&lt;P&gt;#----------------------&lt;/P&gt;

&lt;P&gt;#!/bin/ksh&lt;/P&gt;

&lt;P&gt;# ksh_date_with_d_and_e&lt;BR /&gt;&lt;BR /&gt;
# If current day of the month is greater than 9 then print date time out&lt;BR /&gt;&lt;BR /&gt;
# for the 9th of the month.  Otherwise print out current date time&lt;BR /&gt;&lt;BR /&gt;
#&lt;BR /&gt;&lt;BR /&gt;
DAY=&lt;CODE&gt;date +%e&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
if [ $DAY -gt 9 ]&lt;BR /&gt;&lt;BR /&gt;
then&lt;BR /&gt;&lt;BR /&gt;
     let BACK=$DAY-9&lt;BR /&gt;&lt;BR /&gt;
else&lt;BR /&gt;&lt;BR /&gt;
     BACK=0&lt;BR /&gt;&lt;BR /&gt;
fi&lt;BR /&gt;&lt;BR /&gt;
date -d "$BACK days ago"  +"%y/%d/%m %k:%M:%S"&lt;BR /&gt;&lt;BR /&gt;
date -d "$BACK days ago"  +"%y/%e/%m %k:%M:%S"&lt;BR /&gt;&lt;BR /&gt;
# END  &lt;/P&gt;

&lt;P&gt;SAMPLE OUTPUT:&lt;BR /&gt;&lt;BR /&gt;
11/09/12 10:50:15&lt;BR /&gt;&lt;BR /&gt;
11/ 9/12 10:50:15  &lt;/P&gt;

&lt;P&gt;#----------------------&lt;BR /&gt;&lt;BR /&gt;
#!/usr/bin/python&lt;BR /&gt;&lt;BR /&gt;
# python_date_with_d_and_e"&lt;BR /&gt;&lt;BR /&gt;
# Using hard coded date here&lt;BR /&gt;&lt;BR /&gt;
#&lt;BR /&gt;&lt;BR /&gt;
import time&lt;BR /&gt;&lt;BR /&gt;
t = (2011, 12, 9, 17, 3, 38, 1, 48, 0)&lt;BR /&gt;&lt;BR /&gt;
t = time.mktime(t)&lt;BR /&gt;&lt;BR /&gt;
print time.strftime("%y/%d/%m %k:%M:%S", time.gmtime(t))&lt;BR /&gt;&lt;BR /&gt;
print time.strftime("%y/%e/%m %k:%M:%S", time.gmtime(t))&lt;BR /&gt;&lt;BR /&gt;
# END  &lt;/P&gt;

&lt;P&gt;SAMPLE OUTPUT:&lt;BR /&gt;&lt;BR /&gt;
11/09/12 23:03:38&lt;BR /&gt;&lt;BR /&gt;
11/ 9/12 23:03:38&lt;BR /&gt;&lt;BR /&gt;
#----------------------&lt;BR /&gt;&lt;BR /&gt;
Unless splunk does something special for "%e" different than python or ksh,&lt;BR /&gt;&lt;BR /&gt;
it seems this would still not match for a single character day in date field&lt;BR /&gt;&lt;BR /&gt;
I have not had a chance to experiment further so is still conjecture on my part.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32507#M5782</guid>
      <dc:creator>clmiller</dc:creator>
      <dc:date>2020-09-28T10:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I configure timestamp extraction where day may be one or two digits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32508#M5783</link>
      <description>&lt;P&gt;Yes - it does not do what it is supposed to do. I want to extract the day from "Aug 18 17:11:16" and "Aug  8 17:11:16". %e is not white space padded.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2014 15:31:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-configure-timestamp-extraction-where-day-may-be-one-or/m-p/32508#M5783</guid>
      <dc:creator>FRoth</dc:creator>
      <dc:date>2014-08-18T15:31:20Z</dc:date>
    </item>
  </channel>
</rss>

