<?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 a new fields based on some characters in _raw log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188256#M54238</link>
    <description>&lt;P&gt;I have too many hosts&lt;/P&gt;</description>
    <pubDate>Fri, 14 Mar 2014 13:57:15 GMT</pubDate>
    <dc:creator>splunker12er</dc:creator>
    <dc:date>2014-03-14T13:57:15Z</dc:date>
    <item>
      <title>How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188253#M54235</link>
      <description>&lt;P&gt;I wanted to create a new field name like 'Country' from the incoming logs based on some characters in the hostname.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Raw logs:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Timestamp                    Type         Hostname   Service     Status    
Fri Mar 14 11:16:16 2014 $ SERVICEALERT $ AU_DC_1    $ SERVICE1  $ OK
Fri Mar 14 11:17:11 2014 $ HOSTALERT    $ IN_DC_2    $ SERVICE2  $ WARNING
Fri Mar 14 11:18:12 2014 $ HOSTEALERT   $ SG_DC_1    $ SERVICE3  $ OK
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From the above logs from the HOSTNAME (&lt;CODE&gt;AU_DC,IN_DC,SG_DC&lt;/CODE&gt;) represents Country (&lt;CODE&gt;Australia,India,Singapore&lt;/CODE&gt;)&lt;/P&gt;

&lt;P&gt;I wanted to create a new fields with this how can create it ?&lt;BR /&gt;&lt;BR /&gt;
i tried to tag this , but each time the HOSTNAME may differ , is there any eval commands help?&lt;/P&gt;

&lt;P&gt;please help.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2014 13:46:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188253#M54235</guid>
      <dc:creator>splunker12er</dc:creator>
      <dc:date>2014-03-14T13:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188254#M54236</link>
      <description>&lt;P&gt;How many countries?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2014 13:54:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188254#M54236</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-03-14T13:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188255#M54237</link>
      <description>&lt;P&gt;Hi splunker12er,&lt;/P&gt;

&lt;P&gt;If there only three specfic hosts as you say to can use the eval statment like this in your search&lt;BR /&gt;
query&lt;/P&gt;

&lt;P&gt;[your search ] | eval NEWHOSTNAME=case(hostname==AU_DC,"Australia",hostname==IN_DC,"India",hostname==SD_DC,"Singapore")&lt;/P&gt;

&lt;P&gt;or if the no of hostnames are more you can use lookup .pls refer&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Lookup" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps !&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:08:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188255#M54237</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2020-09-28T16:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188256#M54238</link>
      <description>&lt;P&gt;I have too many hosts&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2014 13:57:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188256#M54238</guid>
      <dc:creator>splunker12er</dc:creator>
      <dc:date>2014-03-14T13:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188257#M54239</link>
      <description>&lt;P&gt;You might need to use the full value:&lt;BR /&gt;
AU_DC_1, IN_DC_2, SG_DC_1&lt;/P&gt;

&lt;P&gt;Also, you might want to include 1==1 as the last case statement to catch unmatched values.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188257#M54239</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2020-09-28T16:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188258#M54240</link>
      <description>&lt;P&gt;I think you could use Lookups for this.  If you have a large list, I think lookups would be the better option for you.  &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usefieldlookupstoaddinformationtoyourevents"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/Knowledge/Addfieldsfromexternaldatasources"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.2/Knowledge/Addfieldsfromexternaldatasources&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You could do a static lookup.  You'd have to make the CSV list of all the hostnames and the country they are associated with, but it would provide you with the data you are looking for and create the Country field automatically.&lt;/P&gt;

&lt;P&gt;To test it you could start off with just a small list.  &lt;/P&gt;

&lt;P&gt;This is also a great blog on how this works. The example is very similar to what you are trying to do.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://blogs.splunk.com/2009/07/27/enriching-data-with-lookups-part-1/"&gt;http://blogs.splunk.com/2009/07/27/enriching-data-with-lookups-part-1/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2014 14:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188258#M54240</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2014-03-14T14:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new fields based on some characters in _raw log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188259#M54241</link>
      <description>&lt;P&gt;You want to add new field, say country with values AU/IN/SG or Australia/India/Singapore? If first, then you just need field extraction (using rex/props.conf). If second, then you need field extraction and lookups both.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2014 15:59:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-fields-based-on-some-characters-in-raw-log/m-p/188259#M54241</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-14T15:59:17Z</dc:date>
    </item>
  </channel>
</rss>

