<?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: Nedd regex help to use part of a filepath as source type in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311016#M174983</link>
    <description>&lt;P&gt;Guiseppe - I would want it at index time. This config is sitting on a heavy weight forwarder. So if I used that config what would my FORMAT field look like in transforms?&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2017 13:20:37 GMT</pubDate>
    <dc:creator>brent_weaver</dc:creator>
    <dc:date>2017-04-05T13:20:37Z</dc:date>
    <item>
      <title>Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311014#M174981</link>
      <description>&lt;P&gt;I have a source of /var/log/opscode/desired_sourcetype/current. I need to get the part of the filename that is called "desired_courcetype" via regex. I am almost there, the rewriting is working great. Here is my config:&lt;/P&gt;

&lt;P&gt;Props:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[chef:server]
NO_BINARY_CHECK = true
SHOULD_LINEMERGE = false
TRANSFORMS-update_metadata = autosource
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Transforms:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[autosource]
DEST_KEY = MetaData:Sourcetype
SOURCE_KEY = MetaData:Source
REGEX = \w+
FORMAT = sourcetype::chef:server:$4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Clearly I am not well versed in regex. So woud would the regex be to capture the 3rd element of the filepath delimited by the /.&lt;/P&gt;

&lt;P&gt;Any help is MUCH appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311014#M174981</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2020-09-29T13:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311015#M174982</link>
      <description>&lt;P&gt;Hi  brent_weaver,&lt;BR /&gt;
do you want to extract this field at search time or at index time?&lt;BR /&gt;
at search time you could use a regex like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\/var\/log\/opscode\/(?&amp;lt;desired_courcetype&amp;gt;[^\/]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;test it at &lt;A href="https://regex101.com/r/8YMnMh/1"&gt;https://regex101.com/r/8YMnMh/1&lt;/A&gt;&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311015#M174982</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-04-05T13:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311016#M174983</link>
      <description>&lt;P&gt;Guiseppe - I would want it at index time. This config is sitting on a heavy weight forwarder. So if I used that config what would my FORMAT field look like in transforms?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311016#M174983</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2017-04-05T13:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311017#M174984</link>
      <description>&lt;P&gt;Also inportant to note that "desired_sourcetype" is variable, that is not a static string.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:41:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311017#M174984</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2017-04-05T13:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311018#M174985</link>
      <description>&lt;P&gt;YOu can just use the same REGEX (minus the name capture), i.e. just &lt;CODE&gt;\/var\/log\/opscode\/([^\/]*)&lt;/CODE&gt; as REGEX in your transforms.conf.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:45:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311018#M174985</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-05T13:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311019#M174986</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[autosource]
SOURCE_KEY = MetaData:Source
REGEX = ^source::(?:/[^/]+){3}/([^/]+)/
FORMAT = sourcetype::chef:server:$1
DEST_KEY = MetaData:Sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:49:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311019#M174986</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-05T13:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Nedd regex help to use part of a filepath as source type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311020#M174987</link>
      <description>&lt;P&gt;Deploy to Indexers (or HFs) and restart splunk instances and verify on NEW events (old events will stay broken).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nedd-regex-help-to-use-part-of-a-filepath-as-source-type/m-p/311020#M174987</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-05T13:51:41Z</dc:date>
    </item>
  </channel>
</rss>

