<?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: taking the source file path and creating a field in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296207#M56172</link>
    <description>&lt;P&gt;This works well, one last question is, what is the syntax for extracting more fields in source? &lt;/P&gt;

&lt;P&gt;putting in in like this only works with the foofoo extraction- &lt;BR /&gt;
[sourcetypename]&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2017 19:28:10 GMT</pubDate>
    <dc:creator>sbattista09</dc:creator>
    <dc:date>2017-05-19T19:28:10Z</dc:date>
    <item>
      <title>taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296201#M56166</link>
      <description>&lt;P&gt;if i wanted to take the app_name from the path of the source and create a field via the CLI of the input how would i do that? I know i could rename the source type however, that is not a option. I want to create a new field based off the 4th position of the source path.&lt;/P&gt;

&lt;P&gt;source =    /foo/app/test/app/app_name/logs/log.log&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 14:32:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296201#M56166</guid>
      <dc:creator>sbattista09</dc:creator>
      <dc:date>2017-05-16T14:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296202#M56167</link>
      <description>&lt;P&gt;use...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=source "^\/[^\/]+\/[^\/]+\/[^\/]+\/(?&amp;lt;myfield&amp;gt;[^\/]+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=source "^\/[^\/]+\/[^\/]+\/[^\/]+\/[^\/]+\/(?&amp;lt;myfield&amp;gt;[^\/]+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...depending on whether your "fourth" was zero-based or one-based.  &lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 14:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296202#M56167</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-16T14:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296203#M56168</link>
      <description>&lt;P&gt;I don't want to do this via a inline search. &lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 18:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296203#M56168</guid>
      <dc:creator>sbattista09</dc:creator>
      <dc:date>2017-05-16T18:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296204#M56169</link>
      <description>&lt;P&gt;You can setup in props.conf of the search head:&lt;/P&gt;

&lt;P&gt;example with source stanza:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/opt/log/*/logs]
EXTRACT-inSource = /opt/log/(?&amp;lt;field1&amp;gt;[^/]+)/logs/.* in source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;example with sourcetype stanza:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
EXTRACT-inSource = /opt/log/(?&amp;lt;field1&amp;gt;[^/]+)/logs/.* in source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 May 2017 18:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296204#M56169</guid>
      <dc:creator>rphillips_splk</dc:creator>
      <dc:date>2017-05-16T18:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296205#M56170</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex field=source "^\/(?:[^\/]+\/){3}(?&amp;lt;app_name&amp;gt;[^\/]+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 May 2017 19:22:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296205#M56170</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-16T19:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296206#M56171</link>
      <description>&lt;P&gt;...then combine rphillips suggestion with either mine or woodcock's - use one of our rex codes, with rphillips' suggestion of where to do it.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 20:27:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296206#M56171</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-16T20:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: taking the source file path and creating a field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296207#M56172</link>
      <description>&lt;P&gt;This works well, one last question is, what is the syntax for extracting more fields in source? &lt;/P&gt;

&lt;P&gt;putting in in like this only works with the foofoo extraction- &lt;BR /&gt;
[sourcetypename]&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;BR /&gt;
EXTRACT-inSource = ^\/[^\/]+\/[^\/]+\/[^\/]+\/[^\/]+\/(?[^\/]+)\/ in source&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:28:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/taking-the-source-file-path-and-creating-a-field/m-p/296207#M56172</guid>
      <dc:creator>sbattista09</dc:creator>
      <dc:date>2017-05-19T19:28:10Z</dc:date>
    </item>
  </channel>
</rss>

