<?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: dynamically assign sourcetype on folder in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281105#M53783</link>
    <description>&lt;P&gt;Hi fredkeiser,&lt;/P&gt;

&lt;P&gt;Your regex is missing the &lt;STRONG&gt;double escaped backslashes&lt;/STRONG&gt; and you can test it with Splunk's internal regex functions:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk cmd pcregextest test_str="C:\Program Files (x86)\LIC\Current\test\filename.log" mregex=".+\\(.+)\\[^\\]*"&lt;/CODE&gt;&lt;BR /&gt;
returns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Original Pattern: '.+\(.+)\[^\]*'
Expanded Pattern: '.+\(.+)\[^\]*'
ERROR: Regex: unmatched parentheses
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But if you double escape the backslashes it works:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk cmd pcregextest test_str="C:\Program Files (x86)\LIC\Current\test\filename.log" mregex=".+\\\(.+)\\\[^\\\]+"&lt;/CODE&gt;&lt;BR /&gt;
returns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Original Pattern: '.+\\(.+)\\[^\\]+'
Expanded Pattern: '.+\\(.+)\\[^\\]+'
Regex compiled successfully. Capture group count = 1. Named capturing groups = 0.
SUCCESS - match against: 'C:\Program Files (x86)\LIC\Current\test\filename.log'

#### Capturing group data ##### 
Group |            Name | Value
--------------------------------------
    1 |                 | test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Mon, 15 Feb 2016 01:42:51 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2016-02-15T01:42:51Z</dc:date>
    <item>
      <title>dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281104#M53782</link>
      <description>&lt;P&gt;I'll like to assign the sourcetype on the folder the logs are sitting in&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;What I have&lt;/EM&gt;&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;File location pick up by forwarder&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Program Files (x86)\License\Current\test\filename.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::C:\\Program Files (x86)\\License\\Current\\*\\*.log] 
TRANSFORMS-set_sourcetype = set_sourcetype_from_log_subdir
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[set_sourcetype_from_log_subdir]
SOURCE_KEY = MetaData:Source
DEST_KEY = MetaData:Sourcetype
REGEX = .+\\(.+)\\[^]*
FORMAT = sourcetype::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk Returns sourcetype as &lt;STRONG&gt;filename&lt;/STRONG&gt; when index&lt;/P&gt;

&lt;P&gt;but I want is the folder not the file name so it should return &lt;STRONG&gt;test&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 01:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281104#M53782</guid>
      <dc:creator>fredkaiser</dc:creator>
      <dc:date>2016-02-15T01:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281105#M53783</link>
      <description>&lt;P&gt;Hi fredkeiser,&lt;/P&gt;

&lt;P&gt;Your regex is missing the &lt;STRONG&gt;double escaped backslashes&lt;/STRONG&gt; and you can test it with Splunk's internal regex functions:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk cmd pcregextest test_str="C:\Program Files (x86)\LIC\Current\test\filename.log" mregex=".+\\(.+)\\[^\\]*"&lt;/CODE&gt;&lt;BR /&gt;
returns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Original Pattern: '.+\(.+)\[^\]*'
Expanded Pattern: '.+\(.+)\[^\]*'
ERROR: Regex: unmatched parentheses
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But if you double escape the backslashes it works:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk cmd pcregextest test_str="C:\Program Files (x86)\LIC\Current\test\filename.log" mregex=".+\\\(.+)\\\[^\\\]+"&lt;/CODE&gt;&lt;BR /&gt;
returns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Original Pattern: '.+\\(.+)\\[^\\]+'
Expanded Pattern: '.+\\(.+)\\[^\\]+'
Regex compiled successfully. Capture group count = 1. Named capturing groups = 0.
SUCCESS - match against: 'C:\Program Files (x86)\LIC\Current\test\filename.log'

#### Capturing group data ##### 
Group |            Name | Value
--------------------------------------
    1 |                 | test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 01:42:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281105#M53783</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-02-15T01:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281106#M53784</link>
      <description>&lt;P&gt;I'll try that as well and still returns the file name as the sourcetype.  even when you test your regex here &lt;A href="http://www.regexr.com/"&gt;http://www.regexr.com/&lt;/A&gt;  it shows it should work.  But for some reason it doesn't  work with Splunk&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 02:11:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281106#M53784</guid>
      <dc:creator>fredkaiser</dc:creator>
      <dc:date>2016-02-15T02:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281107#M53785</link>
      <description>&lt;P&gt;Ahh, sorry my bad ! I'll update the answer ....&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 02:21:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281107#M53785</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-02-15T02:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281108#M53786</link>
      <description>&lt;P&gt;update done&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 02:25:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281108#M53786</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-02-15T02:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281109#M53787</link>
      <description>&lt;P&gt;found the issue was to do with are Props.conf&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::C:\Program Files (x86)\\Current\\*\\*.log] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;should be&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::...\\Current\\*\\*.log]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;everything else was right. &lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 01:00:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281109#M53787</guid>
      <dc:creator>fredkaiser</dc:creator>
      <dc:date>2016-02-17T01:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically assign sourcetype on folder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281110#M53788</link>
      <description>&lt;P&gt;Thanks for the help MuS&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 01:06:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/dynamically-assign-sourcetype-on-folder/m-p/281110#M53788</guid>
      <dc:creator>fredkaiser</dc:creator>
      <dc:date>2016-02-17T01:06:14Z</dc:date>
    </item>
  </channel>
</rss>

