<?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: How to create an interesting field by parsing host name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355132#M170134</link>
    <description>&lt;P&gt;try this:&lt;BR /&gt;
&lt;CODE&gt;... | rex field=host "SRV-\S{2}(?&amp;lt;Environment&amp;gt;\S{3})"&lt;/CODE&gt;&lt;BR /&gt;
hope it helps&lt;/P&gt;</description>
    <pubDate>Sun, 22 Apr 2018 15:04:44 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2018-04-22T15:04:44Z</dc:date>
    <item>
      <title>How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355131#M170133</link>
      <description>&lt;P&gt;my index has events from many hosts. The hosts names contain information about what environment the host is part of. I would like to extract this at index time and make it an interesting field.&lt;/P&gt;

&lt;P&gt;my host names always follow this pattern: SRV-xxP01xxxxx&lt;BR /&gt;
the environment in this host name is "P01",  and environment is always the 7th, 8th and 9th character in the host name string.&lt;/P&gt;

&lt;P&gt;How would I go about making the environment an interesting field for my non-power users?&lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Sun, 22 Apr 2018 14:58:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355131#M170133</guid>
      <dc:creator>rileyken</dc:creator>
      <dc:date>2018-04-22T14:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355132#M170134</link>
      <description>&lt;P&gt;try this:&lt;BR /&gt;
&lt;CODE&gt;... | rex field=host "SRV-\S{2}(?&amp;lt;Environment&amp;gt;\S{3})"&lt;/CODE&gt;&lt;BR /&gt;
hope it helps&lt;/P&gt;</description>
      <pubDate>Sun, 22 Apr 2018 15:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355132#M170134</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-22T15:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355133#M170135</link>
      <description>&lt;P&gt;Are you &lt;EM&gt;SURE&lt;/EM&gt; that you need it at index-time?  I will give you that answer but suspect that you would be better off by a search-time solution.&lt;BR /&gt;
You you need this in #props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[(::){0}*]
TRANSFORMS-GLOBAL_environment_from_host = environment_from_host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you need this in #transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[environment_from_host]
SOURCE_KEY = MetaData:Host
REGEX = ^.{6}(?&amp;lt;environment&amp;gt;.{3})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you can get by with a search-time solution, then change &lt;CODE&gt;TRANSFORMS-&lt;/CODE&gt; to &lt;CODE&gt;REPORT-&lt;/CODE&gt; in #props.conf and change &lt;CODE&gt;SOURCE_KEY = MetaData:Host&lt;/CODE&gt; to &lt;CODE&gt;SOURCE_KEY = host&lt;/CODE&gt; in #transforms.conf.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Apr 2018 16:04:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355133#M170135</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-04-22T16:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355134#M170136</link>
      <description>&lt;P&gt;The solution provided does not work. I did some digging and found this article, which was simalar&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.splunk.com/blog/2014/07/31/quick-tip-wildcard-sourcetypes-in-props-conf.html"&gt;https://www.splunk.com/blog/2014/07/31/quick-tip-wildcard-sourcetypes-in-props-conf.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;maybe the issue is this bit:   [(::){0}*]&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 09:00:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355134#M170136</guid>
      <dc:creator>rileyken</dc:creator>
      <dc:date>2018-04-24T09:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355135#M170137</link>
      <description>&lt;P&gt;The solution would be to apply a regex to extract the environment from the hostname. As a result the we i the props.conf you need to apply this to all host&lt;/P&gt;

&lt;P&gt;props.conf&lt;BR /&gt;
****************************************************************&lt;BR /&gt;
[host::*]&lt;BR /&gt;
TRANSFORMS-GLOBAL_environment_from_host = environment_from_host&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;In the transform.conf we need to specify source key for the regex as MetaData:Host , apply the regex  and since this is a new field you have apply WRITE_META = true.&lt;/P&gt;

&lt;P&gt;transform.conf&lt;BR /&gt;
******************************************************************&lt;BR /&gt;
[environment_from_host]&lt;BR /&gt;
SOURCE_KEY = MetaData:Host&lt;BR /&gt;
REGEX =  "APPLY YOUR Regex HERE"&lt;BR /&gt;
FORMAT = env::$1&lt;BR /&gt;
WRITE_META = true&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;PLease be sure to apply your correct regex&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:12:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355135#M170137</guid>
      <dc:creator>dbarnesroomstog</dc:creator>
      <dc:date>2020-09-29T19:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355136#M170138</link>
      <description>&lt;P&gt;This solution works.  Remember you said &lt;CODE&gt;index-time&lt;/CODE&gt; so you need to deploy it to your Indexer tiers, restart splunk on each Indexer, and then check against events that were indexed AFTER the restart.  Did you do all of that?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 15:41:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355136#M170138</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-04-24T15:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an interesting field by parsing host name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355137#M170139</link>
      <description>&lt;P&gt;Thats what was done and the solution didnt work.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 15:46:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-interesting-field-by-parsing-host-name/m-p/355137#M170139</guid>
      <dc:creator>dbarnesroomstog</dc:creator>
      <dc:date>2018-04-24T15:46:55Z</dc:date>
    </item>
  </channel>
</rss>

