<?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 Set Field based on another field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90558#M23260</link>
    <description>&lt;P&gt;I am trying to create a field that contains information about the type of host based on the host field.  For example, I have DMZ servers and Private servers.  DMZ servers always have a hostname that ends in a "z" and Private servers always have a hostname that end in a "p".  I would like to create a field to equal "DMZ" when the host ends in "z" and "Private" when host ends in "p".&lt;/P&gt;

&lt;P&gt;There might be an easier way to do this but my ultimate goal is to timechart certain logs by location of servers.  SO if I have 20 servers on the DMZ and 80 servers on the Private LAN all servers will be grouped by location in a timechart.  (hope this make sense to somebody &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;example:
....|timechart count by LocationField&lt;/P&gt;

&lt;P&gt;I am a Splunk newbie so please forgive me if I am going about this the wrong way.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Nov 2010 05:54:46 GMT</pubDate>
    <dc:creator>axsolis</dc:creator>
    <dc:date>2010-11-17T05:54:46Z</dc:date>
    <item>
      <title>Set Field based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90558#M23260</link>
      <description>&lt;P&gt;I am trying to create a field that contains information about the type of host based on the host field.  For example, I have DMZ servers and Private servers.  DMZ servers always have a hostname that ends in a "z" and Private servers always have a hostname that end in a "p".  I would like to create a field to equal "DMZ" when the host ends in "z" and "Private" when host ends in "p".&lt;/P&gt;

&lt;P&gt;There might be an easier way to do this but my ultimate goal is to timechart certain logs by location of servers.  SO if I have 20 servers on the DMZ and 80 servers on the Private LAN all servers will be grouped by location in a timechart.  (hope this make sense to somebody &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;example:
....|timechart count by LocationField&lt;/P&gt;

&lt;P&gt;I am a Splunk newbie so please forgive me if I am going about this the wrong way.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2010 05:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90558#M23260</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2010-11-17T05:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Set Field based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90559#M23261</link>
      <description>&lt;P&gt;You can use the case statement in eval to do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval LocationField = case(host LIKE "%p", "private", host LIKE "%z", "DMZ")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Nov 2010 06:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90559#M23261</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-11-17T06:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Set Field based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90560#M23262</link>
      <description>&lt;P&gt;This will do it. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt;  | eval hostType=if(substr(host,-1)=="z","DMZ","private")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Nov 2010 06:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90560#M23262</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-11-17T06:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Set Field based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90561#M23263</link>
      <description>&lt;P&gt;Thanks!  that woked!  Now is there a way to place this in some sort of function so I do not have to write the entire case() portion again?  Or is there a way to make the LocationField permanent so LocationField will always come up in results?&lt;/P&gt;

&lt;P&gt;Thanks for any help provided!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 21:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90561#M23263</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2010-11-18T21:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set Field based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90562#M23264</link>
      <description>&lt;P&gt;I'd recommend making a search macro for this. You'd then invoke as: ... | &lt;CODE&gt;setlocation&lt;/CODE&gt; | ...&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 22:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-Field-based-on-another-field/m-p/90562#M23264</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-11-18T22:38:33Z</dc:date>
    </item>
  </channel>
</rss>

