<?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: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52167#M12658</link>
    <description>&lt;P&gt;If the lookup tables and tagging mentioned in the two answers you linked in your question do not work for you, you could define your server groups with wildcards. Such as doing a search for&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=host1* OR host=host2*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, could you define the hosts by a search? Then you could use a &lt;A href="http://www.splunk.com/base/Documentation/4.1.5/User/HowSubsearchesWork" rel="nofollow"&gt;subsearch&lt;/A&gt; to define your hosts and push them to your desired search. This might be possible if your hosts have some distinct attribute you can search on. If all the desired hosts for example have a source in common, for example they all index an example.log file, you could craft your search as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search terms [ search source="*example.log" | fields + host]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Sep 2010 19:44:18 GMT</pubDate>
    <dc:creator>ftk</dc:creator>
    <dc:date>2010-09-16T19:44:18Z</dc:date>
    <item>
      <title>Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52166#M12657</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;We want to search for hundreds of hosts at a time. The question is similar to these:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/questions/968/how-can-i-easily-filter-or-limit-my-search-down-to-a-specific-group-of-hosts" rel="nofollow"&gt;http://answers.splunk.com/questions/968/how-can-i-easily-filter-or-limit-my-search-down-to-a-specific-group-of-hosts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;^ Globbing is not good because a full text expansion will not match groups like the one in the title. Tags would be in the order of hundreds which becomes difficult to maintain.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/questions/730/how-to-search-multiple-value-on-the-same-field/734#734" rel="nofollow"&gt;http://answers.splunk.com/questions/730/how-to-search-multiple-value-on-the-same-field/734#734&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;^ This is more promising, but not ideal for a managed installation where clients may use it, as the csv has to exist in a dir on the server.&lt;/P&gt;

&lt;P&gt;What are the alternatives?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 18:16:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52166#M12657</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-16T18:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52167#M12658</link>
      <description>&lt;P&gt;If the lookup tables and tagging mentioned in the two answers you linked in your question do not work for you, you could define your server groups with wildcards. Such as doing a search for&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=host1* OR host=host2*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, could you define the hosts by a search? Then you could use a &lt;A href="http://www.splunk.com/base/Documentation/4.1.5/User/HowSubsearchesWork" rel="nofollow"&gt;subsearch&lt;/A&gt; to define your hosts and push them to your desired search. This might be possible if your hosts have some distinct attribute you can search on. If all the desired hosts for example have a source in common, for example they all index an example.log file, you could craft your search as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search terms [ search source="*example.log" | fields + host]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Sep 2010 19:44:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52167#M12658</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2010-09-16T19:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52168#M12659</link>
      <description>&lt;P&gt;Globbing/wildcards does not work with the example provided unfortunately. For example host1* matches host1, host10, host100, host1000 and all in between. There's no way to specify host321-host426 for example, using wildcards.&lt;/P&gt;

&lt;P&gt;A full pattern match or range operator [] would suffice, but as I understand it that's currently not possible.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 19:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52168#M12659</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-16T19:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52169#M12660</link>
      <description>&lt;P&gt;I recommend putting in an Enhancement Request for that feature. What about the subsearch?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 20:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52169#M12660</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2010-09-16T20:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52170#M12661</link>
      <description>&lt;P&gt;You could use the same technique as described in the following answer: &lt;A href="http://answers.splunk.com/questions/6856/regular-expression-in-search" rel="nofollow"&gt;http://answers.splunk.com/questions/6856/regular-expression-in-search&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Specifying something like host321 - host426 is possible, but a little more complicated:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* [ | metadata type=hosts | rex field=host "^host(?&amp;lt;host_no&amp;gt;\d+)" | where host_no&amp;gt;=321 AND host_no&amp;lt;=426 | fields host ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;P&gt;As subsearches are quite limited (default to 100 results), here is a slower, but less limited variant (just as an alternative):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=3* OR host=4* | rex field=host "^host(?&amp;lt;host_no&amp;gt;\d+)" | where host_no&amp;gt;=321 AND host_no&amp;lt;=426
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Sep 2010 21:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52170#M12661</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-09-16T21:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52171#M12662</link>
      <description>&lt;P&gt;great idea ziegfried&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 21:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52171#M12662</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2010-09-16T21:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52172#M12663</link>
      <description>&lt;P&gt;Liking this idea very much, but | metadata queries on hosts only returns 10000 results :[ (afaik this is hardcoded limitation) - the use case I'm looking at has in excess of that number. We may have to yield to generating plaintext files with the groups, and getting Splunk to index them so they can be returned with a simple subsearch for the sourcefile with a group listing. Something along those lines...&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 21:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52172#M12663</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-16T21:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52173#M12664</link>
      <description>&lt;P&gt;Subsearch is the way to go I think, just need to find an optimal way of getting the data in there.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 21:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52173#M12664</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-16T21:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52174#M12665</link>
      <description>&lt;P&gt;Subsearches are limited as well... See &lt;A href="http://www.splunk.com/base/Documentation/latest/Admin/Limitsconf"&gt;http://www.splunk.com/base/Documentation/latest/Admin/Limitsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 21:53:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52174#M12665</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-09-16T21:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52175#M12666</link>
      <description>&lt;P&gt;At least that limit can be changed!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2010 19:08:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52175#M12666</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-17T19:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for large groups of hosts (or any other field), i.e. host=box[100-200].domain.com</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52176#M12667</link>
      <description>&lt;P&gt;Responding here to get the full formatting - this was solved using a combination of the above, although it's perhaps not as suitable as more advanced pattern matching on the host string.&lt;/P&gt;

&lt;P&gt;Create a file (call it grp1) with desired list of hosts inside. In this case I had a file containing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;box1.*
box2.*
box1500.*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... and so on&lt;/P&gt;

&lt;P&gt;You need to get Splunk to index this file, go w/o linemerge (use a newline breaker)&lt;/P&gt;

&lt;P&gt;For whatever strange reason,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields +host 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Displays the host field twice, and causes a strange artifact with | format, making your string look like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;OR ( host=box1.domain.com host=box1.* ) OR ( host=box1.domain.com host=box1.* )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The | rex overcomes this problem, so the final search string (to search for all hosts you listed in the file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mydata [ search source=*grp1* | rex field=_raw "host=(?&amp;lt;host&amp;gt;.*)" | fields + host | format ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch returns the results for the host group, the main search provides the data. &lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2010 19:50:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-large-groups-of-hosts-or-any-other-field-i-e-host/m-p/52176#M12667</guid>
      <dc:creator>parallaxed</dc:creator>
      <dc:date>2010-09-17T19:50:47Z</dc:date>
    </item>
  </channel>
</rss>

