<?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 How do i extract data from my event source filename in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370515#M67232</link>
    <description>&lt;P&gt;I have multiple logfiles like TEST_SRC_FR.txt, TEST_SRC_IN.txt,  TEST_SRC_AU.txt which are my source files.   Now i want to extract the last two letters like "FR" from TEST_SRC_FR.txt.&lt;/P&gt;

&lt;P&gt;Any idea how to get them during search time.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Pradipta&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:02:22 GMT</pubDate>
    <dc:creator>pradiptam</dc:creator>
    <dc:date>2020-09-29T18:02:22Z</dc:date>
    <item>
      <title>How do i extract data from my event source filename</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370515#M67232</link>
      <description>&lt;P&gt;I have multiple logfiles like TEST_SRC_FR.txt, TEST_SRC_IN.txt,  TEST_SRC_AU.txt which are my source files.   Now i want to extract the last two letters like "FR" from TEST_SRC_FR.txt.&lt;/P&gt;

&lt;P&gt;Any idea how to get them during search time.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Pradipta&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:02:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370515#M67232</guid>
      <dc:creator>pradiptam</dc:creator>
      <dc:date>2020-09-29T18:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract data from my event source filename</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370516#M67233</link>
      <description>&lt;P&gt;try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval _raw="TEST_SRC_FR.txt"|rex ".*_(?&amp;lt;name&amp;gt;\w{2})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in your case you can use as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;indexname&amp;gt;| rex field=source ".*_(?&amp;lt;name&amp;gt;\w{2})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;also you can make this regex in props.conf&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 19:02:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370516#M67233</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T19:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract data from my event source filename</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370517#M67234</link>
      <description>&lt;P&gt;Sure!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source "(?&amp;lt;LastTwoLetters&amp;gt;..)\.txt$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That assume they're the literal field &lt;CODE&gt;source&lt;/CODE&gt; and that they ALWAYS end with "txt".  &lt;/P&gt;

&lt;P&gt;Modifications can be made for other similar scenarios, but you'll have to be very specific in describing them.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Happy Splunking,&lt;BR /&gt;
Rich&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 19:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370517#M67234</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-02-08T19:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract data from my event source filename</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370518#M67235</link>
      <description>&lt;P&gt;Great its working fine for me.&lt;/P&gt;

&lt;P&gt;regards,&lt;BR /&gt;
Pradipta&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 05:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370518#M67235</guid>
      <dc:creator>pradiptam</dc:creator>
      <dc:date>2018-02-09T05:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract data from my event source filename</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370519#M67236</link>
      <description>&lt;P&gt;Thanks its also working, checking which one to use in my program&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Pradipta&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 05:54:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-i-extract-data-from-my-event-source-filename/m-p/370519#M67236</guid>
      <dc:creator>pradiptam</dc:creator>
      <dc:date>2018-02-09T05:54:43Z</dc:date>
    </item>
  </channel>
</rss>

