<?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: Odd or even host in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65426#M16245</link>
    <description>&lt;P&gt;I would recommend using a macro instead of an eventtype in this case. Defining the eventtype will make searches slower, as the eventtype not only expands the search, but then all results are checked against the list of possible eventtypes for a match. Using a macro will just expand the search terms, without doing the typing on the results.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2011 05:16:51 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2011-03-23T05:16:51Z</dc:date>
    <item>
      <title>Odd or even host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65424#M16243</link>
      <description>&lt;P&gt;My company has a server naming convention that specifies a number
Server01
Server02
Server03
Server04 -&amp;gt; Server100&lt;/P&gt;

&lt;P&gt;How would i go about creating a search that would show events from Odd or Even numbered host names only?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2011 03:36:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65424#M16243</guid>
      <dc:creator>johnmca</dc:creator>
      <dc:date>2011-03-23T03:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Odd or even host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65425#M16244</link>
      <description>&lt;P&gt;There may be a better way, but this will work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search_terms | rex field=host "Server(?&amp;lt;hostdigit&amp;gt;\d+)" | eval oddhost=hostdigit % 2 | where oddhost=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Oddhost will be set to 0 or 1 depending on whether the host id is odd or even.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Another approach that appears to work could be done with eventtypes.  You would define two eventtypes, one for "oddhost" and one for "evenhost", similar to this, in eventtypes.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[oddhost]
search = ( host="Server*1" OR host="Server*3" OR host="Server*5" OR host="Server*7" OR host="Server*9" )

[evenhost]
search = ( host="Server*0" OR host="Server*2" OR host="Server*4" OR host="Server*6" OR host="Server*8" )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;More info on eventtypes at &lt;A href="http://www.splunk.com/base/Documentation/latest/Knowledge/Abouteventtypes" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/Knowledge/Abouteventtypes&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Given Gerald's recommendation of a macro, you can do something like this in macros.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[evenhost]
definition = ( host="Server*0" OR host="Server*2" OR host="Server*4" OR host="Server*6" OR host="Server*8" )

[oddhost]
definition = ( host="Server*1" OR host="Server*3" OR host="Server*5" OR host="Server*7" OR host="Server*9" )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/Admin/Macrosconf" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/Admin/Macrosconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/User/CreateAndUseSearchMacros" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/User/CreateAndUseSearchMacros&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2011 04:09:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65425#M16244</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-03-23T04:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Odd or even host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65426#M16245</link>
      <description>&lt;P&gt;I would recommend using a macro instead of an eventtype in this case. Defining the eventtype will make searches slower, as the eventtype not only expands the search, but then all results are checked against the list of possible eventtypes for a match. Using a macro will just expand the search terms, without doing the typing on the results.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2011 05:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65426#M16245</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-03-23T05:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Odd or even host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65427#M16246</link>
      <description>&lt;P&gt;The macro will possibly be a bit faster than using rex, but you should try them both a few times, then use the Search Inspector to see which goes faster. Be sure to turn off "Field Discovery" when benchmarking.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2011 05:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Odd-or-even-host/m-p/65427#M16246</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-03-23T05:19:00Z</dc:date>
    </item>
  </channel>
</rss>

