<?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 host_regex is not setting correct hostname in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157122#M185793</link>
    <description>&lt;P&gt;Thanks, I'll try to contact the app author.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Oct 2014 11:24:39 GMT</pubDate>
    <dc:creator>jrodman</dc:creator>
    <dc:date>2014-10-09T11:24:39Z</dc:date>
    <item>
      <title>why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157117#M185788</link>
      <description>&lt;P&gt;I'm trying to  set hostnames extracting them from filenames&lt;BR /&gt;
I'm using host_regex with this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host_regex = (myserver[1-2].mydomain.com)\W+\w+\.s$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The paths are in this form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/path/to/files/mail.text.myserver1.mydomain.com.@20141009T084808.s
/path/to/files/mail.text.myserver2.mydomain.com.@20141009T104107.s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried different rex all matching correctly "myserver[1-2].mydomain.com" but in Splunk hostname is always set to default value (Splunk server hostname)&lt;/P&gt;

&lt;P&gt;Anyone have some ideas to get it working?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 09:31:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157117#M185788</guid>
      <dc:creator>vzzbrs</dc:creator>
      <dc:date>2014-10-09T09:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157118#M185789</link>
      <description>&lt;P&gt;I'm kind of confused about &lt;CODE&gt;\W+\w+\.s$&lt;/CODE&gt; I guess &lt;CODE&gt;\W&lt;/CODE&gt; will match the .@ and the &lt;CODE&gt;\w&lt;/CODE&gt; will match the timestamp?&lt;/P&gt;

&lt;P&gt;I suppose a regex tester shows a successful match anyway.  Probably this is not a regex problem.&lt;/P&gt;

&lt;P&gt;Please show the whole input stanza, and let us know the sourcetype that is being applied to the data?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 10:00:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157118#M185789</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2014-10-09T10:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157119#M185790</link>
      <description>&lt;P&gt;Yes, you're correct: &lt;CODE&gt;\W&lt;/CODE&gt; is for matching .@ and &lt;CODE&gt;\w&lt;/CODE&gt; for the timestamp and a regex tester shows succeful match.&lt;BR /&gt;
The sourcetype is cisco-esa because I'm using  the app "Add-on for Cisco ESA"&lt;BR /&gt;
This is the input stanza I'm using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///path/to/file]
source = cisco:esa
sourcetype = cisco:esa
host_regex = (myserver[1-2].mydomain.com)\W+\w+\.s$
disabled = false
host =
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure about that "host =" but is added by the web GUI. I already tried to remove it from the inputs.conf file but nothing changed&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 10:51:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157119#M185790</guid>
      <dc:creator>vzzbrs</dc:creator>
      <dc:date>2014-10-09T10:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157120#M185791</link>
      <description>&lt;P&gt;Okay, the problem is now clear with your provided input stanza.&lt;/P&gt;

&lt;P&gt;From the inputs.conf.spec file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host_regex = &amp;lt;regular expression&amp;gt;
* If specified, &amp;lt;regular expression&amp;gt; extracts host from the path to the file for each input file.
    * Detail: This feature examines the source key, so if source is set
      explicitly in the stanza, that string will be matched, not the original filename.
* Specifically, the first group of the regex is used as the host.
* If the regex fails to match, the default "host =" attribute is used.
* If host_regex and host_segment are both set, host_regex will be ignored.
* Defaults to unset.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;host_regex uses the source value to extract from.  However, you're overriding the value that the file-input code would provide with &lt;CODE&gt;source=cisco:esa&lt;/CODE&gt;, removing the information you want host_regex to use.  You should probably just remove the &lt;CODE&gt;source=cisco:esa&lt;/CODE&gt; line.&lt;/P&gt;

&lt;P&gt;This is anti-recommended in the spec as well.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source = &amp;lt;string&amp;gt;
* Sets the source key/field for events from this input.
* NOTE: Overriding the source key is generally not recommended.  Typically, the
  input layer will provide a more accurate string to aid in problem
  analysis and investigation, accurately recording the file from which the data
  was retreived.  Please consider use of source types, tagging, and search
  wildcards before overriding this value.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:50:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157120#M185791</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2020-09-28T17:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157121#M185792</link>
      <description>&lt;P&gt;Thanks jrodman,&lt;BR /&gt;
removing &lt;CODE&gt;source=cisco:esa&lt;/CODE&gt; solved the issue&lt;BR /&gt;
It was there because I took the starting inputs.conf from the app README file&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 11:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157121#M185792</guid>
      <dc:creator>vzzbrs</dc:creator>
      <dc:date>2014-10-09T11:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: why host_regex is not setting correct hostname</title>
      <link>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157122#M185793</link>
      <description>&lt;P&gt;Thanks, I'll try to contact the app author.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 11:24:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/why-host-regex-is-not-setting-correct-hostname/m-p/157122#M185793</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2014-10-09T11:24:39Z</dc:date>
    </item>
  </channel>
</rss>

