<?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: extract field from the source's file path and make it the host field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212753#M62351</link>
    <description>&lt;P&gt;Ok try it with the last update I provided which adds&lt;BR /&gt;
 FORMAT = host::$1&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2016 17:01:40 GMT</pubDate>
    <dc:creator>cramasta</dc:creator>
    <dc:date>2016-04-28T17:01:40Z</dc:date>
    <item>
      <title>extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212742#M62340</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I am trying to extract the field from the log file path which includes the actual host. currently, the host field is populated with the third segment of the log file path that is the clientid field. But what we want is the actual host name . we are currently indexing from a shared mount which is the reason not able to capture the actual host name &lt;/P&gt;

&lt;P&gt;Example  source field with log file name &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/emp_logs-sc9/loaner/DE123456/EmpServer.DE123456.SC9VEABE1092.2014-04-13-11.log. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;current host field - DE123456 &lt;/P&gt;

&lt;P&gt;expected host field - SC9VEABE1092&lt;/P&gt;

&lt;P&gt;can someone guide me, how to achieve this? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 18:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212742#M62340</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2016-04-22T18:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212743#M62341</link>
      <description>&lt;P&gt;on your indexer you can try something like this. these changes require a restart of the indexer&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#props.conf
[source::/emp_logs-sc9/loaner/DE123456/*]
TRANSFORMS-hostFromSource=hostFromSource


#transforms.conf
[hostFromSource]
SOURCE_KEY = MetaData:Source
REGEX=.*\/.*?\..*?\.(\w+)
FORMAT = $1
DEST_KEY= MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The regex really just needs to be something that has a capturing group of what you want the hostname to be when ran against the source.  There may be a better regular expression depending on what the rest of your logs source paths look like.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:18:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212743#M62341</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-22T19:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212744#M62342</link>
      <description>&lt;P&gt;one day Ill eventually figure out how to get formatting to work on this site.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212744#M62342</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-22T19:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212745#M62343</link>
      <description>&lt;P&gt;Thanks cramasta,&lt;/P&gt;

&lt;P&gt;all my log files are of the same format. the clientid and hostname in the source changes. &lt;/P&gt;

&lt;P&gt;/emp_logs-sc9/loaner/DE123456/EmpServer.DE123456.SC9VEABE1092.2014-04-13-11.log. &lt;/P&gt;

&lt;P&gt;DE123456 is actually the clientid &lt;/P&gt;

&lt;P&gt;but in the fourth segment "EmpServer.DE123456.SC9VEABE1092.2014-04-13-11.log"  the hostname is SC9VEABE1092. This is what we want to replace the host field with. &lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:46:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212745#M62343</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2016-04-22T19:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212746#M62344</link>
      <description>&lt;P&gt;so it seem like you get the basic idea here, i just captured the wrong part of the group.  All you have to do is change the regex to capture that group.  Also updated my original answer&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;.*\/.*?\..*?\.(\w+)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212746#M62344</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-22T19:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212747#M62345</link>
      <description>&lt;P&gt;or something like this for your regex.  theres more than one way to write the regex depending on what the sources look like.&lt;BR /&gt;
&lt;CODE&gt;EmpServer\.\w+\.(\w+)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212747#M62345</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-22T19:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212748#M62346</link>
      <description>&lt;P&gt;did this end up working? if so please mark this as accepted. thanks&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 03:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212748#M62346</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-26T03:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212749#M62347</link>
      <description>&lt;P&gt;I tried this out, but did not work in props and transforms settings with regex.  It works with rex in search though.&lt;/P&gt;

&lt;P&gt;Props.conf:&lt;/P&gt;

&lt;P&gt;[source::/emp_logs*/.../*.log]&lt;BR /&gt;
TRANSFORMS-hostFromSource=hostFromSource&lt;/P&gt;

&lt;P&gt;transforms.conf :&lt;/P&gt;

&lt;P&gt;[hostFromSource]&lt;BR /&gt;
SOURCE_KEY = MetaData:Source&lt;BR /&gt;
REGEX=EmpServer.\w+.(\w+)&lt;BR /&gt;
FORMAT = $1&lt;BR /&gt;
DEST_KEY= MetaData:Host&lt;/P&gt;

&lt;P&gt;and here is the rex search which worked in over-riding the host field&lt;/P&gt;

&lt;P&gt;index="emp_logs" | rex field=source "EmpServer.[A-Za-z0-9]*.(?P[^.]+)" &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:34:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212749#M62347</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2020-09-29T09:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212750#M62348</link>
      <description>&lt;P&gt;Did you put this setting on your indexers?&lt;/P&gt;

&lt;P&gt;Does using the regex that you are putting in your props.conf work in search with rex? &lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 16:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212750#M62348</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-28T16:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212751#M62349</link>
      <description>&lt;P&gt;Try this, didnt think its needed buy maybe it is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Props.conf:

[source::/emp_logs*/.../*.log]
TRANSFORMS-hostFromSource=hostFromSource

transforms.conf :

[hostFromSource]
SOURCE_KEY = MetaData:Source
REGEX=EmpServer.\w+.(\w+)
FORMAT = host::$1
DEST_KEY= MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2016 16:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212751#M62349</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-28T16:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212752#M62350</link>
      <description>&lt;P&gt;I tried this.. did not work. &lt;BR /&gt;
transforms.conf&lt;/P&gt;

&lt;P&gt;[hostFromSource]&lt;BR /&gt;
SOURCE_KEY = MetaData:Source&lt;BR /&gt;
REGEX=EmpServer.[A-Za-z0-9]*.([^.]+)&lt;BR /&gt;
FORMAT = $1&lt;BR /&gt;
DEST_KEY= MetaData:Host&lt;/P&gt;

&lt;P&gt;Let me try the updated one&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212752#M62350</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2020-09-29T09:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212753#M62351</link>
      <description>&lt;P&gt;Ok try it with the last update I provided which adds&lt;BR /&gt;
 FORMAT = host::$1&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 17:01:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212753#M62351</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-28T17:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212754#M62352</link>
      <description>&lt;P&gt;tried this.. still doesn't work&lt;/P&gt;

&lt;P&gt;[hostFromSource]&lt;BR /&gt;
SOURCE_KEY = MetaData:Source&lt;BR /&gt;
REGEX=EmpServer.[A-Za-z0-9]*.([^.]+)&lt;BR /&gt;
FORMAT = host::$1&lt;BR /&gt;
DEST_KEY= MetaData:Host&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212754#M62352</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2020-09-29T09:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212755#M62353</link>
      <description>&lt;P&gt;and you put this on the indexers where the data is being collected?&lt;/P&gt;

&lt;P&gt;Can you also try hardcoding in a specific current source in your props.conf to make sure we its not the wildcards/ ... thats throwing it off. &lt;BR /&gt;
 [source::/emp_logs-sc9/loaner/DE123456/EmpServer.DE123456.SC9VEABE1092.2016-04-30-X.log]&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 18:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212755#M62353</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2016-04-28T18:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from the source's file path and make it the host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212756#M62354</link>
      <description>&lt;P&gt;HI Cramasta,&lt;/P&gt;

&lt;P&gt;Sorry was out for while, But I did try this, still not working.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 18:16:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-the-source-s-file-path-and-make-it-the-host/m-p/212756#M62354</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2016-05-10T18:16:04Z</dc:date>
    </item>
  </channel>
</rss>

