<?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 Dynamic Hostname based on actual host name + sourcetype in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61685#M12310</link>
    <description>&lt;P&gt;Monitoring a directory with a bunch of files in it.  Only want the .log files from the directory.&lt;/P&gt;

&lt;P&gt;Changing the sourcetype based on the file name.&lt;/P&gt;

&lt;P&gt;Now I want to change the hostname based on the file name.  I saw an example on Splunkbase and tried using it below unsuccessfully.    In the end, based on the file name, I want to assign different values to the hostname.&lt;/P&gt;

&lt;P&gt;if the file matches the pattern, CAPPM*.log, then I want the hostname to be HOSTNAME (computer) + the source type from the props.conf (ex.   njros1bva0597_SOURCE1)&lt;/P&gt;

&lt;P&gt;if the file matches the pattern, ex*.log, then I want the hostname to be HOSTNAME (computer) + the source type from props.conf (ex.   njros1bva0597_SOURCE2)&lt;/P&gt;

&lt;P&gt;Below is my probably feeble attempt.&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;BR /&gt;
[monitor://\njros1bva0597\d$\LogFiles\W3SVC1]&lt;BR /&gt;
disabled = 0&lt;BR /&gt;
host = NJROS1BVA0621ABC&lt;BR /&gt;
index=imaging&lt;BR /&gt;
whitelist = .log$&lt;/P&gt;

&lt;P&gt;Props.conf&lt;BR /&gt;
[source::...\CAPPM*.log] &lt;BR /&gt;
sourcetype = SOURCE1 &lt;/P&gt;

&lt;P&gt;[source::...\ex*.log] &lt;BR /&gt;
sourcetype = SOURCE2&lt;/P&gt;

&lt;P&gt;[SOURCE2]&lt;BR /&gt;
TRANSFORMS-hostname = esx_remap_host&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;BR /&gt;
[esx_remap_host]&lt;BR /&gt;
SOURCE_KEY = MetaData:Source&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;BR /&gt;
REGEX = /dir1/dir2/(.+)/ex120110.log&lt;BR /&gt;
FORMAT = host::$1&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:27:12 GMT</pubDate>
    <dc:creator>peter_gianusso</dc:creator>
    <dc:date>2020-09-28T12:27:12Z</dc:date>
    <item>
      <title>Dynamic Hostname based on actual host name + sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61685#M12310</link>
      <description>&lt;P&gt;Monitoring a directory with a bunch of files in it.  Only want the .log files from the directory.&lt;/P&gt;

&lt;P&gt;Changing the sourcetype based on the file name.&lt;/P&gt;

&lt;P&gt;Now I want to change the hostname based on the file name.  I saw an example on Splunkbase and tried using it below unsuccessfully.    In the end, based on the file name, I want to assign different values to the hostname.&lt;/P&gt;

&lt;P&gt;if the file matches the pattern, CAPPM*.log, then I want the hostname to be HOSTNAME (computer) + the source type from the props.conf (ex.   njros1bva0597_SOURCE1)&lt;/P&gt;

&lt;P&gt;if the file matches the pattern, ex*.log, then I want the hostname to be HOSTNAME (computer) + the source type from props.conf (ex.   njros1bva0597_SOURCE2)&lt;/P&gt;

&lt;P&gt;Below is my probably feeble attempt.&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;BR /&gt;
[monitor://\njros1bva0597\d$\LogFiles\W3SVC1]&lt;BR /&gt;
disabled = 0&lt;BR /&gt;
host = NJROS1BVA0621ABC&lt;BR /&gt;
index=imaging&lt;BR /&gt;
whitelist = .log$&lt;/P&gt;

&lt;P&gt;Props.conf&lt;BR /&gt;
[source::...\CAPPM*.log] &lt;BR /&gt;
sourcetype = SOURCE1 &lt;/P&gt;

&lt;P&gt;[source::...\ex*.log] &lt;BR /&gt;
sourcetype = SOURCE2&lt;/P&gt;

&lt;P&gt;[SOURCE2]&lt;BR /&gt;
TRANSFORMS-hostname = esx_remap_host&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;BR /&gt;
[esx_remap_host]&lt;BR /&gt;
SOURCE_KEY = MetaData:Source&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;BR /&gt;
REGEX = /dir1/dir2/(.+)/ex120110.log&lt;BR /&gt;
FORMAT = host::$1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:27:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61685#M12310</guid>
      <dc:creator>peter_gianusso</dc:creator>
      <dc:date>2020-09-28T12:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Hostname based on actual host name + sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61686#M12311</link>
      <description>&lt;P&gt;have you tried &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.3/Data/Setadefaulthostforaninput#Dynamically_set_the_default_host_value"&gt;regex on path&lt;/A&gt; in inputs.conf with following parameter?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host_regex=
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2012 19:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61686#M12311</guid>
      <dc:creator>MarioM</dc:creator>
      <dc:date>2012-09-17T19:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Hostname based on actual host name + sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61687#M12312</link>
      <description>&lt;P&gt;Sorry...Should have stated I wanted to append the source type from the props.conf to the actual host name.  The appending of the 2 would be the source name I wanted.&lt;/P&gt;

&lt;P&gt;I don't think doing that in inputs.conf will do that because props.conf has not been executed.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2012 19:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Dynamic-Hostname-based-on-actual-host-name-sourcetype/m-p/61687#M12312</guid>
      <dc:creator>peter_gianusso</dc:creator>
      <dc:date>2012-09-17T19:40:35Z</dc:date>
    </item>
  </channel>
</rss>

