<?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: hosts with certain criteria (simplified REGEX) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173262#M49681</link>
    <description>&lt;P&gt;thank you all for your inputs. I think this will work but I will ask Martin if this will filter out the hosts on the first pass.&lt;/P&gt;

&lt;P&gt;index=foo (host=*pr1p*1 OR host=*pr1p*3 OR host=*pr1p*5 OR host=*pr1p*7 OR host=*pr1p*9) | ...&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 20:20:45 GMT</pubDate>
    <dc:creator>Noorzaie</dc:creator>
    <dc:date>2020-09-28T20:20:45Z</dc:date>
    <item>
      <title>hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173248#M49667</link>
      <description>&lt;P&gt;I  want to pull data for certain HOSTs in my index. For example:&lt;BR /&gt;
(host=*pr1p01 OR host=*pr1p03 OR host=*pr1p05 .. ) - servers with ODD or EVEN numbers.&lt;/P&gt;

&lt;P&gt;Appreciate the help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173248#M49667</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2020-09-28T20:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173249#M49668</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where match(host, ".*[13579]$")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval evenOrOdd = if(match(host, ".*[13579]$"), "ODD", "EVEN") | where evenOrOdd="ODD"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2015 18:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173249#M49668</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-23T18:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173250#M49669</link>
      <description>&lt;P&gt;I would like to specifically include only HOSTs with *pr1p0[02468] or *pr1p0[13579]&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 18:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173250#M49669</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2015-06-23T18:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173251#M49670</link>
      <description>&lt;P&gt;How is that different from 'host=*pr1p0[0-9]'?  What exactly are you trying to accomplish?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 18:54:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173251#M49670</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-23T18:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173252#M49671</link>
      <description>&lt;P&gt;My objective is to query against the hosts whose names end with ODD numbers but begins with *pr1p.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:03:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173252#M49671</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2015-06-23T19:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173253#M49672</link>
      <description>&lt;P&gt;I'm confused by your stated desire to include hosts that end with '[02468]', but woodcock's first suggestion should do the job.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where match(host, ".*pr1p0[13579]$")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173253#M49672</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-23T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173254#M49673</link>
      <description>&lt;P&gt;If you really only have five matching hosts in each group then I'd strongly recommend tagging each host with either odd or event and searching like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex tag::host=odd | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this is just a simple example for a more complex or even unknown list of hosts then tagging is not going to work. For performance reasons I'd advise this slightly more complicated solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex [tstats count where index=yourindex AND host=*pr1p0* by host | where match(host, "pr1p0[13579]$") | fields host] | rest of the search pipeline
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will generate a tailored search filter for Splunk to only look at matching hosts' events. With the late &lt;CODE&gt;|where&lt;/CODE&gt; in the other suggestions Splunk has to load events from non-matching hosts, process them, and then discard them again. Sloooow.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:24:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173254#M49673</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-23T19:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173255#M49674</link>
      <description>&lt;P&gt;OK, I think you are looking for this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... regex host=".*\d+$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But really we can't say for sure because your question and followup comments are SO contradictory and unclear.  You definitely need the &lt;CODE&gt;regex host=&lt;/CODE&gt; command but until you can be PERFECTLY CLEAR about what you are trying to match, we cannot help you.  The regex in my solution matches any host that ends in a digit.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173255#M49674</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-23T19:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173256#M49675</link>
      <description>&lt;P&gt;Let me try to to explain one more time &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
I have this query:&lt;BR /&gt;
index=my-ndx "some criteria" (host=*pr1p01 OR host=*pr1p03 OR host=*pr1p05 OR host=*pr1p07 OR host=*pr1p09 OR host=*pr1p11) | stats pipeline&lt;/P&gt;

&lt;P&gt;My list of hosts is growing and there are other hosts that i don't want to include (hence the criteria), so instead of adding the additional hosts to the OR criteria, can I use regex or similar to get data with only hosts matching this criteria?&lt;/P&gt;

&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173256#M49675</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2020-09-28T20:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173257#M49676</link>
      <description>&lt;P&gt;Does @woodcock's first answer,   &lt;CODE&gt;| where match(host, ".*[13579]$")&lt;/CODE&gt; not work ?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 20:26:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173257#M49676</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-06-23T20:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173258#M49677</link>
      <description>&lt;P&gt;No, it returns hosts outside the criteria "*pr1p". I want only hosts with "*pr1p01", "*pr1p03" and so forth.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:21:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173258#M49677</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2020-09-28T20:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173259#M49678</link>
      <description>&lt;P&gt;So you just need &lt;CODE&gt;| where match(host, ".*pr1p[13579]$")&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 20:32:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173259#M49678</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-06-23T20:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173260#M49679</link>
      <description>&lt;P&gt;Your second search is, as us kids say, "money".&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://photos.vanityfair.com/2014/07/10/53beb048d547558a0d7364ae_guy-fieri.gif" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 21:53:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173260#M49679</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-06-23T21:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173261#M49680</link>
      <description>&lt;P&gt;I'll send you my paypal &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 21:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173261#M49680</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-23T21:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173262#M49681</link>
      <description>&lt;P&gt;thank you all for your inputs. I think this will work but I will ask Martin if this will filter out the hosts on the first pass.&lt;/P&gt;

&lt;P&gt;index=foo (host=*pr1p*1 OR host=*pr1p*3 OR host=*pr1p*5 OR host=*pr1p*7 OR host=*pr1p*9) | ...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173262#M49681</guid>
      <dc:creator>Noorzaie</dc:creator>
      <dc:date>2020-09-28T20:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173263#M49682</link>
      <description>&lt;P&gt;See my latest answer regarding &lt;CODE&gt;eventtypes&lt;/CODE&gt; (immediately forthcoming)...&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 22:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173263#M49682</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-23T22:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173264#M49683</link>
      <description>&lt;P&gt;This will work as long as you have no host called pr1pfoo1 that's not supposed to be matched. Regex'ing for digits would filter it out, this wildcard would not.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 22:17:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173264#M49683</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-23T22:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173265#M49684</link>
      <description>&lt;P&gt;Given this clarification:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;My list of hosts is growing and there are other hosts that i don't want to include (hence the criteria), so instead of adding the additional hosts to the OR criteria, can I use regex or similar to get data with only hosts matching this criteria?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I assume your concern is housekeeping, not complexity nor filtering, per se.  If so, then the solution is to create an &lt;CODE&gt;eventtype&lt;/CODE&gt; and make sure that all of your users and searches use it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=SpecialHosts ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you modify this ONE definition in ONE place ( &lt;CODE&gt;eventtypes.conf&lt;/CODE&gt; ) as often as needed and when you save it, INSTANTLY everything else is updated:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[SpecialHosts]
index=my-ndx "some criteria" (host=*pr1p01 OR host=*pr1p03 OR host=*pr1p05 OR host=*pr1p07 OR host=*pr1p09 OR host=*pr1p11)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2015 22:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173265#M49684</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-23T22:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173266#M49685</link>
      <description>&lt;P&gt;Did this work?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 05:10:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173266#M49685</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-07T05:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: hosts with certain criteria (simplified REGEX)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173267#M49686</link>
      <description>&lt;P&gt;also syntax is host_regex instead of regex host&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/Admin/Inputsconf"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/Admin/Inputsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 17:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/hosts-with-certain-criteria-simplified-REGEX/m-p/173267#M49686</guid>
      <dc:creator>bjcross</dc:creator>
      <dc:date>2019-09-12T17:28:17Z</dc:date>
    </item>
  </channel>
</rss>

