<?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: Timestamp from file name in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67234#M13508</link>
    <description>&lt;P&gt;Here's what you need to do :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Write your own regular expression which will extract the month, the day and the year from your event source each in its own capture group. &lt;/LI&gt;
&lt;LI&gt;Include your regex in a custom &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Configuretimestamprecognition#Splunk.27s_timestamp_processor" target="_blank"&gt;datetime.xml&lt;/A&gt; file. You should use &lt;CODE&gt;$SPLUNK_HOME/etc/datetime.xml&lt;/CODE&gt; as a reference for the format to use for your own custom datetime.xml&lt;/LI&gt;
&lt;LI&gt;Set up &lt;CONFIG&gt;DATETIME_CONFIG in props.conf so that it would use your custom datetime.xml file.&lt;/CONFIG&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Just to get you started, here's what you'll probably want to have in your own instance of datetime.xml to extract dates from your file source :&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
&lt;DEFINE name="_sourcedate" extract="month, day, year"&gt;&lt;BR /&gt;
    &lt;TEXT&gt;&amp;lt;![CDATA[(?:^|source::).*?_(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])-(20\d\d|19\d\d|[901]\d(?!\d))\.csv]]&amp;gt;&lt;/TEXT&gt; &lt;BR /&gt;
&lt;/DEFINE&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;TIMEPATTERNS&gt;&lt;BR /&gt;
(...)&lt;BR /&gt;
&lt;/TIMEPATTERNS&gt;&lt;BR /&gt;
&lt;DATEPATTERNS&gt;&lt;BR /&gt;
(...)&lt;BR /&gt;
      &lt;USE name="_sourcedate"&gt;&lt;/USE&gt;&lt;BR /&gt;
&lt;/DATEPATTERNS&gt;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The easy way to go about this would be to copy &lt;CODE&gt;$SPLUNK_HOME/etc/datetime.xml&lt;/CODE&gt; to your custom app and then add the regular expression definition at the end of the existing ones, and reference it under &lt;CODE&gt;&lt;DATEPATTERNS&gt;&lt;/DATEPATTERNS&gt;&lt;/CODE&gt; as shown above.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 10:24:09 GMT</pubDate>
    <dc:creator>hexx</dc:creator>
    <dc:date>2020-09-28T10:24:09Z</dc:date>
    <item>
      <title>Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67233#M13507</link>
      <description>&lt;P&gt;I have file names like this "Patch-Data_2-1-2012.csv" &lt;/P&gt;

&lt;P&gt;How do I use the date in the file name for the datestamp for all the lines/events in the file&lt;/P&gt;

&lt;P&gt;This is a one shot import&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2012 22:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67233#M13507</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2012-02-07T22:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67234#M13508</link>
      <description>&lt;P&gt;Here's what you need to do :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Write your own regular expression which will extract the month, the day and the year from your event source each in its own capture group. &lt;/LI&gt;
&lt;LI&gt;Include your regex in a custom &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Configuretimestamprecognition#Splunk.27s_timestamp_processor" target="_blank"&gt;datetime.xml&lt;/A&gt; file. You should use &lt;CODE&gt;$SPLUNK_HOME/etc/datetime.xml&lt;/CODE&gt; as a reference for the format to use for your own custom datetime.xml&lt;/LI&gt;
&lt;LI&gt;Set up &lt;CONFIG&gt;DATETIME_CONFIG in props.conf so that it would use your custom datetime.xml file.&lt;/CONFIG&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Just to get you started, here's what you'll probably want to have in your own instance of datetime.xml to extract dates from your file source :&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
&lt;DEFINE name="_sourcedate" extract="month, day, year"&gt;&lt;BR /&gt;
    &lt;TEXT&gt;&amp;lt;![CDATA[(?:^|source::).*?_(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])-(20\d\d|19\d\d|[901]\d(?!\d))\.csv]]&amp;gt;&lt;/TEXT&gt; &lt;BR /&gt;
&lt;/DEFINE&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;TIMEPATTERNS&gt;&lt;BR /&gt;
(...)&lt;BR /&gt;
&lt;/TIMEPATTERNS&gt;&lt;BR /&gt;
&lt;DATEPATTERNS&gt;&lt;BR /&gt;
(...)&lt;BR /&gt;
      &lt;USE name="_sourcedate"&gt;&lt;/USE&gt;&lt;BR /&gt;
&lt;/DATEPATTERNS&gt;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The easy way to go about this would be to copy &lt;CODE&gt;$SPLUNK_HOME/etc/datetime.xml&lt;/CODE&gt; to your custom app and then add the regular expression definition at the end of the existing ones, and reference it under &lt;CODE&gt;&lt;DATEPATTERNS&gt;&lt;/DATEPATTERNS&gt;&lt;/CODE&gt; as shown above.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67234#M13508</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2020-09-28T10:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67235#M13509</link>
      <description>&lt;P&gt;hi guys, I have tried replicating this same config and filename on Splunk 5.0.2 but it is not working for me&lt;/P&gt;

&lt;P&gt;any known issues on Splunk 5 about this??&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2013 03:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67235#M13509</guid>
      <dc:creator>asimagu</dc:creator>
      <dc:date>2013-07-31T03:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67236#M13510</link>
      <description>&lt;P&gt;@asimagu&lt;BR /&gt;
Hi, I've had the same problem, couldn't get it to work at all, Splunk used the modification date instead.&lt;/P&gt;

&lt;P&gt;I ended up with overriding _time by using EVAL in props.conf. Not the most elegant solution, but it works for now.&lt;/P&gt;

&lt;P&gt;However, it would be nicer to do it at index time as it should, so I really hope you fint a solution that works for me as well &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2013 05:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67236#M13510</guid>
      <dc:creator>gelica</dc:creator>
      <dc:date>2013-07-31T05:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67237#M13511</link>
      <description>&lt;P&gt;It seems a time is necessary at least.&lt;/P&gt;

&lt;P&gt;"If no events in a source have a date, Splunk Enterprise tries to find one in the source name or file name. (This requires that the events have a time, even though they don't have a date.)"&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2015 16:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67237#M13511</guid>
      <dc:creator>kiddo258</dc:creator>
      <dc:date>2015-01-22T16:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp from file name</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67238#M13512</link>
      <description>&lt;P&gt;props.conf:::::&lt;BR /&gt;
[mysourcetype]&lt;BR /&gt;
TRANSFORMS-change_time= change_time&lt;/P&gt;

&lt;P&gt;transforms.conf:::::&lt;BR /&gt;
[change_time]&lt;BR /&gt;
INGEST_EVAL = _time  = strptime ( replace(source,".+(\d+-\d+-\d+).+", "\1"), "%H-%M-%S")&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:20:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Timestamp-from-file-name/m-p/67238#M13512</guid>
      <dc:creator>duncanzhang</dc:creator>
      <dc:date>2020-09-30T01:20:42Z</dc:date>
    </item>
  </channel>
</rss>

