<?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: Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209061#M41163</link>
    <description>&lt;P&gt;Can you try to see if &lt;CODE&gt;host_segment&lt;/CODE&gt; is what you are looking for to create the host names based on the directory paths. For example in below the host is picked up from 4th element in the directory path as &lt;CODE&gt;abc-host*&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputs.conf
[monitor:///myLogDirectory/myRegionDirectory/myEnvDirectory/abc-host*/xyz.log]
host_segment = 4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Dec 2016 22:32:42 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-12-27T22:32:42Z</dc:date>
    <item>
      <title>Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209059#M41161</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I have a set of directories (syslog collector), created for  logs from remote hosts and containing hostnames in the name. While indexing in Splunk, I need all the data to be mapped to the same source (source=myhosts) to avoid creating new source for new files.&lt;BR /&gt;
Also I need to extract hostnames from the path, so I use 'regex on path'.&lt;/P&gt;

&lt;P&gt;The issue is that when I create Input via Splunk Web, the regex works just fine and my host=remotehostname, but I can't declare source value.&lt;BR /&gt;
When I create input in inputs.conf  with the same regex, my host=splunkhostname.&lt;/P&gt;

&lt;P&gt;The regex looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.*\/work\/SPLUNK\_HOSTS\_\/(?\S[^\/]+).*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I fix it?&lt;/P&gt;

&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 18:09:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209059#M41161</guid>
      <dc:creator>evelenke</dc:creator>
      <dc:date>2016-12-27T18:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209060#M41162</link>
      <description>&lt;P&gt;Are you overriding the &lt;CODE&gt;source&lt;/CODE&gt; attribute in inputs.conf and then &lt;CODE&gt;host = .*\/work\/SPLUNK\_HOSTS\_\/(?\S[^\/]+).*&lt;/CODE&gt; is not working? Mind sharing your inputs.conf entry (full)?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 19:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209060#M41162</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-27T19:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209061#M41163</link>
      <description>&lt;P&gt;Can you try to see if &lt;CODE&gt;host_segment&lt;/CODE&gt; is what you are looking for to create the host names based on the directory paths. For example in below the host is picked up from 4th element in the directory path as &lt;CODE&gt;abc-host*&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputs.conf
[monitor:///myLogDirectory/myRegionDirectory/myEnvDirectory/abc-host*/xyz.log]
host_segment = 4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2016 22:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209061#M41163</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-27T22:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209062#M41164</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Here's my stanzas. Sorry, but I  have to change names&lt;/P&gt;

&lt;P&gt;[monitor:///work/VENDOR_DEVICES_/mydevice.mydomain.com]&lt;BR /&gt;
disabled = false&lt;BR /&gt;
index = vendor&lt;BR /&gt;
source = vendor_model&lt;BR /&gt;
host_regex = &lt;CODE&gt;.*DEVICES\_\/(?&amp;lt;host&amp;gt;\S[^\/]+).*&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The source value is unique for this type of devices &lt;/P&gt;

&lt;P&gt;Also I had to mention the folder structure inside each folder like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/work/VENDOR_DEVICES_/mydevice.mydomain.com/2016/2016-12/2016-12-28/mydevice.mydomain.com_20161228.txt
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209062#M41164</guid>
      <dc:creator>evelenke</dc:creator>
      <dc:date>2020-09-29T12:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does set host by 'regex on path' work differently between Splunk Web and inputs.conf?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209063#M41165</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;strange , but host_segment doesn't work from inputs.conf neither...&lt;BR /&gt;
Strictly declared host (&lt;CODE&gt;host=mydevicename&lt;/CODE&gt;) works fine.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 12:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-set-host-by-regex-on-path-work-differently-between/m-p/209063#M41165</guid>
      <dc:creator>evelenke</dc:creator>
      <dc:date>2016-12-28T12:00:56Z</dc:date>
    </item>
  </channel>
</rss>

