<?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: SPL: extract logfile name from source field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342661#M101488</link>
    <description>&lt;P&gt;Sorry I had my question mark in the wrong place.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 12:51:21 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2017-04-21T12:51:21Z</dc:date>
    <item>
      <title>SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342655#M101482</link>
      <description>&lt;P&gt;Hi, I am trying to setup a dropdown bar for a dashboard and would like to setup dynamic inputs based on the source log file, as there are many different sites being built and torn down.&lt;/P&gt;

&lt;P&gt;example source log name:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;D:\Apache\logs\example.com.au_accessLog_2017-04-20-00_00_00.log  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to extract "example.com.au" from the above source log file and drop everything else. Then make it a distinct value. This value would then be selectable in the dropdown bar to filter on that site.&lt;/P&gt;

&lt;P&gt;This is what I've attempted but is not returning what I need.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=example sourcetype=test:access | eval baseurl = mvindex(split(source,"/", -1) | top baseurl
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 23:50:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342655#M101482</guid>
      <dc:creator>danielsofoulis</dc:creator>
      <dc:date>2017-04-20T23:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342656#M101483</link>
      <description>&lt;P&gt;The following should work for you to extract the part you want from the &lt;CODE&gt;source&lt;/CODE&gt; field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=example sourcetype=test:access | rex field=source "\\(?P&amp;lt;file&amp;gt;[^_\\]+)_[^\\]$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:13:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342656#M101483</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-04-21T00:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342657#M101484</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;...| rex field=source "logs\\(?&amp;lt;fqdn&amp;gt;\S+)_accessLog" | top fqdn
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:19:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342657#M101484</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-04-21T00:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342658#M101485</link>
      <description>&lt;P&gt;Thank you for answering. I ran the search with the rex you provided and got the following error:&lt;BR /&gt;
Error in 'rex' command: Encountered the following error while compiling the regex '(?P[^&lt;EM&gt;]+)&lt;/EM&gt;[^]$': Regex: missing terminating ] for character class &lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:39:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342658#M101485</guid>
      <dc:creator>danielsofoulis</dc:creator>
      <dc:date>2017-04-21T00:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342659#M101486</link>
      <description>&lt;P&gt;Hi thanks for you help, but I'm also getting an error when I run your rex:&lt;BR /&gt;
Error in 'rex' command: Encountered the following error while compiling the regex 'logs(&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:40:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342659#M101486</guid>
      <dc:creator>danielsofoulis</dc:creator>
      <dc:date>2017-04-21T00:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342660#M101487</link>
      <description>&lt;P&gt;I've managed to get it working using &lt;BR /&gt;
rex field=source "\w+\(?P[\w+]+)_accessLog\S+$"| top 20 site&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:57:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342660#M101487</guid>
      <dc:creator>danielsofoulis</dc:creator>
      <dc:date>2017-04-21T00:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: extract logfile name from source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342661#M101488</link>
      <description>&lt;P&gt;Sorry I had my question mark in the wrong place.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 12:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-extract-logfile-name-from-source-field/m-p/342661#M101488</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-04-21T12:51:21Z</dc:date>
    </item>
  </channel>
</rss>

