<?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 Can search deal with bracket expansions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268261#M80688</link>
    <description>&lt;P&gt;I'm using splunk in HPC use cases that can span hundreds or even thousands of machines contiguously or potentially in segmented ranges.  Although we have a convention, I find it hard at times to scope searches over a complete desired range of a given condition.&lt;/P&gt;

&lt;P&gt;I would like to be able to do something like:&lt;/P&gt;

&lt;P&gt;host=host[0001-0877,0899,1300-2350] but that doesn't seem to work.  Is there another way to kind of dynamically scope ranges like this?  I say dynamic because it isn't, and almost never will, be the exact same range per circumstance.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Dec 2015 15:44:53 GMT</pubDate>
    <dc:creator>mjones414</dc:creator>
    <dc:date>2015-12-09T15:44:53Z</dc:date>
    <item>
      <title>Can search deal with bracket expansions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268261#M80688</link>
      <description>&lt;P&gt;I'm using splunk in HPC use cases that can span hundreds or even thousands of machines contiguously or potentially in segmented ranges.  Although we have a convention, I find it hard at times to scope searches over a complete desired range of a given condition.&lt;/P&gt;

&lt;P&gt;I would like to be able to do something like:&lt;/P&gt;

&lt;P&gt;host=host[0001-0877,0899,1300-2350] but that doesn't seem to work.  Is there another way to kind of dynamically scope ranges like this?  I say dynamic because it isn't, and almost never will, be the exact same range per circumstance.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 15:44:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268261#M80688</guid>
      <dc:creator>mjones414</dc:creator>
      <dc:date>2015-12-09T15:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can search deal with bracket expansions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268262#M80689</link>
      <description>&lt;P&gt;This isn't a great answer but you could do something like this in the immediate term&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=host* sourcetype=foo | rex field=host "\w+(?&amp;lt;host_num&amp;gt;\d+)" | search host_num &amp;gt; 877 ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could also bake the field extraction into your configs like this so the field is there for searching prior to the first pipe. One of the issues with the above is that it will return all of the events and then strip out those you don't want which isn't efficient.&lt;/P&gt;

&lt;P&gt;Props&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[foo]
EXTRACT-foo_host_num = \w+(?&amp;lt;host_num&amp;gt;\d+) in host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Beyond that I'm curious if anyone else has a different solution to this as I'd be interested as well!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 16:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268262#M80689</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-12-09T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can search deal with bracket expansions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268263#M80690</link>
      <description>&lt;P&gt;Define a macro like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[filter_range(4)]
args = field,prefix,from,to
definition = [localop | stats count | eval count = mvrange($from$,$to$) | mvexpand count | eval $field$ = "$prefix$".count | fields $field$]
errormsg = oops!
iseval = 0
validation = isnum(from) AND isnum(to)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`filter_range(host,foo,100,200)` OR `filter_range(host,foo,900,950)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Each call to the macro will generate a list of &lt;CODE&gt;host=foo100&lt;/CODE&gt; to &lt;CODE&gt;host=foo200&lt;/CODE&gt; (exclusive) OR'd together, by default limited to 10000 rows per subsearch. If you need zero-prefixes you will need to do a bit of formatting in the &lt;CODE&gt;eval&lt;/CODE&gt;, and maybe add a fifth argument to tell how wide your number should be... or just add the 0 to the prefix.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 17:36:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-search-deal-with-bracket-expansions/m-p/268263#M80690</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-12-09T17:36:35Z</dc:date>
    </item>
  </channel>
</rss>

