<?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: transform hostname based on log filename? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275295#M52809</link>
    <description>&lt;P&gt;Thanks, but we hope to do some transform based on segment 3, e.g. &lt;/P&gt;

&lt;P&gt;/data/asav/gw1new/log.1.gz&lt;/P&gt;

&lt;P&gt;host_rex = 3 gives gw1new.  Then we hope to do something like: &lt;/P&gt;

&lt;P&gt;echo gw1new | sed 's/(gw[0-9])new$/mail\1/g' &lt;/P&gt;

&lt;P&gt;that gives mailgw1.&lt;/P&gt;

&lt;P&gt;Possible to do so?&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2017 10:29:33 GMT</pubDate>
    <dc:creator>stwong</dc:creator>
    <dc:date>2017-02-03T10:29:33Z</dc:date>
    <item>
      <title>transform hostname based on log filename?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275293#M52807</link>
      <description>&lt;P&gt;Hi, we're going to monitor following files on a host with universal forwarder installed:&lt;/P&gt;

&lt;P&gt;/data/asav/gw1new/log1.gz&lt;BR /&gt;
/data/asav/gw2new/log1.gz&lt;BR /&gt;
/data/asav/gw3new/log1.gz&lt;/P&gt;

&lt;P&gt;Since there is no hostname recorded in the log, we want to set hostname like this  for stanza [monitor:///data/asav/gw*/*gz]:&lt;/P&gt;

&lt;P&gt;gw1new -&amp;gt; mailgw1&lt;BR /&gt;
gw2new -&amp;gt; mailgw2&lt;BR /&gt;
gw3new -&amp;gt; mailgw3&lt;/P&gt;

&lt;P&gt;Would anyone please help?&lt;BR /&gt;
Thanks a lot.&lt;/P&gt;

&lt;P&gt;/ST Wong&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:42:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275293#M52807</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2020-09-29T12:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: transform hostname based on log filename?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275294#M52808</link>
      <description>&lt;P&gt;Check this inputs.conf setting:&lt;BR /&gt;
&lt;STRONG&gt;host_segment = *integer&lt;/STRONG&gt;* &lt;BR /&gt;
Sets the segment of the path as the host, using &lt;EM&gt;integer&lt;/EM&gt; to determine the segment. &lt;BR /&gt;
For example, if host_segment = 2, host becomes the second segment of the path. Path segments are separated by the '/' character.&lt;/P&gt;

&lt;P&gt;Source: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.2/Data/Monitorfilesanddirectorieswithinputs.conf"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.2/Data/Monitorfilesanddirectorieswithinputs.conf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 08:52:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275294#M52808</guid>
      <dc:creator>mirkoneverstops</dc:creator>
      <dc:date>2017-02-03T08:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: transform hostname based on log filename?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275295#M52809</link>
      <description>&lt;P&gt;Thanks, but we hope to do some transform based on segment 3, e.g. &lt;/P&gt;

&lt;P&gt;/data/asav/gw1new/log.1.gz&lt;/P&gt;

&lt;P&gt;host_rex = 3 gives gw1new.  Then we hope to do something like: &lt;/P&gt;

&lt;P&gt;echo gw1new | sed 's/(gw[0-9])new$/mail\1/g' &lt;/P&gt;

&lt;P&gt;that gives mailgw1.&lt;/P&gt;

&lt;P&gt;Possible to do so?&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 10:29:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275295#M52809</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2017-02-03T10:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: transform hostname based on log filename?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275296#M52810</link>
      <description>&lt;P&gt;Yes, with a transform like:&lt;/P&gt;

&lt;P&gt;[rename_gw_hostname]&lt;BR /&gt;
SOURCE_KEY = MetaData:Host&lt;BR /&gt;
REGEX    = host::(\w\w\d)new&lt;BR /&gt;
FORMAT = host::mail$1&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;/P&gt;

&lt;P&gt;Applied with props like:&lt;BR /&gt;
[host::gw*new]&lt;BR /&gt;
TRANSFORMS-rename_gw_hostname = rename_gw_hostname&lt;/P&gt;

&lt;P&gt;I didn't tested it but it should work.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275296#M52810</guid>
      <dc:creator>mirkoneverstops</dc:creator>
      <dc:date>2020-09-29T12:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: transform hostname based on log filename?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275297#M52811</link>
      <description>&lt;P&gt;It works! Thanks a lot for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 06:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/transform-hostname-based-on-log-filename/m-p/275297#M52811</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2017-02-06T06:29:55Z</dc:date>
    </item>
  </channel>
</rss>

