<?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: Extract data from filename in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564009#M196467</link>
    <description>&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Data/HowSplunkextractstimestamps#How_Splunk_software_assigns_timestamps" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Data/HowSplunkextractstimestamps#How_Splunk_software_assigns_timestamps&lt;/A&gt;&amp;nbsp;for how Splunk assigns timestamps.&amp;nbsp; This happens at index time.&amp;nbsp; If it isn't happening then make sure the TIME_FORMAT setting is correct (%m_%d_%Y_%H_%M_%S).&lt;/P&gt;&lt;P&gt;You may be able to extract the times at search time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo source="trace_*"
| rex field=source "trace_(?&amp;lt;sourceTime&amp;gt;[^\.]+)"
| eval _time=strptime(sourceTime, "%m_%d_%Y_%H_%M_%S")
| timechart span=1h count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Aug 2021 12:46:06 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-08-23T12:46:06Z</dc:date>
    <item>
      <title>Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/563951#M196446</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;I have a a job log file, that gets ingested to Splunk with naming convention "trace_08_19_2021_06_36_03_*********.txt". After trace, the format of the log file is _MM_DD_YYYY_HH_Min_Sec.****. Requirement is to extract the date and time from the file name and show the no. of the logs that get generated in an hour.&lt;/P&gt;&lt;P&gt;I read a blog which mentioned that Splunk extracts the timestamp from filename, but that's not happening with this case.&lt;/P&gt;&lt;P&gt;Kindly help with this case. Thanks in advance for any assistance.&lt;/P&gt;&lt;P&gt;Regards, Karthikeyan.SV&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 12:47:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/563951#M196446</guid>
      <dc:creator>Karthikeyan</dc:creator>
      <dc:date>2021-08-19T12:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564009#M196467</link>
      <description>&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Data/HowSplunkextractstimestamps#How_Splunk_software_assigns_timestamps" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Data/HowSplunkextractstimestamps#How_Splunk_software_assigns_timestamps&lt;/A&gt;&amp;nbsp;for how Splunk assigns timestamps.&amp;nbsp; This happens at index time.&amp;nbsp; If it isn't happening then make sure the TIME_FORMAT setting is correct (%m_%d_%Y_%H_%M_%S).&lt;/P&gt;&lt;P&gt;You may be able to extract the times at search time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo source="trace_*"
| rex field=source "trace_(?&amp;lt;sourceTime&amp;gt;[^\.]+)"
| eval _time=strptime(sourceTime, "%m_%d_%Y_%H_%M_%S")
| timechart span=1h count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 12:46:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564009#M196467</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-08-23T12:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564295#M196573</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The proposed extract string worked. The file naming convention is "trace_mm_dd_yyyy_hh_MM_ss_&amp;lt;ramdom data&amp;gt;. txt, where random data like 1342_30bfb72c_9f70_4e32_ad3a_3066dd187240. The random data shown here is an example. The extract string we used extracts the data from filename after trace_ till the end before ".". Is it possible to extract the data between trace_ till _&amp;lt;random data&amp;gt;.txt ?&lt;/P&gt;&lt;P&gt;Karthikeyan&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 10:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564295#M196573</guid>
      <dc:creator>Karthikeyan</dc:creator>
      <dc:date>2021-08-23T10:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564320#M196585</link>
      <description>&lt;P&gt;Try this regex&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;trace_(?&amp;lt;sourceTime&amp;gt;\d\d_\d\d_\d\d\d\d_\d\d_\d\d_\d\d)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 23 Aug 2021 12:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564320#M196585</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-08-23T12:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564588#M196675</link>
      <description>&lt;P&gt;I ran into an issue with the search command.&lt;/P&gt;&lt;P&gt;index=foo source="trace_*"&lt;BR /&gt;| rex field=source "trace_(?&amp;lt;sourceTime&amp;gt;[^\.]+)"&lt;BR /&gt;| eval _time=strptime(sourceTime, "%m_%d_%Y_%H_%M_%S")&lt;BR /&gt;| timechart span=1h count&lt;/P&gt;&lt;P&gt;When I use the above command, to see the data for 24 hrs, the count for each hour is displayed which is not a correct value. But when I tried to see events for particular hour, directly by accessing the events of an hour, the same search query was used without timechart and this provides increased no. of events which is actually the correct value to be displayed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 17:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564588#M196675</guid>
      <dc:creator>Karthikeyan</dc:creator>
      <dc:date>2021-08-24T17:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564590#M196676</link>
      <description>&lt;P&gt;Please post a new question for this problem.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 17:23:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-from-filename/m-p/564590#M196676</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-08-24T17:23:44Z</dc:date>
    </item>
  </channel>
</rss>

