<?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: Best place to filter out on field in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263301#M50511</link>
    <description>&lt;P&gt;Thanks, so I'm trying to combine the two answers here - where would you put the lookup on this one?&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2016 11:33:59 GMT</pubDate>
    <dc:creator>a212830</dc:creator>
    <dc:date>2016-10-18T11:33:59Z</dc:date>
    <item>
      <title>Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263298#M50508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following query to report on license utilization, and now want to filter out on specific slave indexers:&lt;/P&gt;

&lt;P&gt;index=_internal source=*license_usage.log type="Usage" | join type=left i &lt;BR /&gt;
      [rest count=0 /services/licenser/slaves &lt;BR /&gt;
      | rename label as slave &lt;BR /&gt;
      | rename title as i &lt;BR /&gt;
      | table i slave] | eval indexname = if(len(idx)=0 OR isnull(idx),"(UNKNOWN)",idx) | eval sourcetypename = st | bin _time span=1d | stats sum(b) as b by _time, slave, st  | eval GB=round(b/1024/1024/1024, 3) | fields _time, slave, st, GB &lt;/P&gt;

&lt;P&gt;How would I do that, and where's the best place to put the filter in this query from a performance perspective?  For example, I want a set of slaves, not all - slave=myservera OR slave=myserverb.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:29:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263298#M50508</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2020-09-29T11:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263299#M50509</link>
      <description>&lt;P&gt;The rule is to insert your  filter as first as possible, possibly in the first search.&lt;BR /&gt;
To search for a set of slaves, the best way is to create a lookup countaining your slaves and put it in your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*license_usage.log type="Usage" | join type=left i [rest count=0 /services/licenser/slaves | rename label as slave | search [ | inputlookup slave_lookup.csv | table slave] | rename title as i | table i slave] | eval indexname = if(len(idx)=0 OR isnull(idx),"(UNKNOWN)",idx) | eval sourcetypename = st | bin _time span=1d | stats sum(b) as b by _time, slave, st | eval GB=round(b/1024/1024/1024, 3) | fields _time, slave, st, GB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Eventually you could put slaves values in your lookup with a scheduled report to run every night or more frequently.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 10:33:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263299#M50509</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-10-18T10:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263300#M50510</link>
      <description>&lt;P&gt;Try filtering as early as possible by using fields and drop any fields you don't want to use.&lt;BR /&gt;
Also if you are going to use stats and join, wait until you have summarised your data with stats first before you join it.&lt;/P&gt;

&lt;P&gt;Your initial query took &lt;STRONG&gt;150 seconds&lt;/STRONG&gt; to complete in my lab.&lt;BR /&gt;
The query below took &lt;STRONG&gt;22 seconds&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*license_usage.log type="Usage"
| fields _time, st, b, i
| bin _time span=1d 
| stats sum(b) as GB by _time, st, i
| eval GB=round(GB/1024/1024/1024, 3)
| rename st as sourcetypename
| join type=left i [
    | rest count=0 /services/licenser/slaves 
    | rename label as slave 
    | rename title as i 
    | table i slave
]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Oct 2016 11:08:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263300#M50510</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-18T11:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263301#M50511</link>
      <description>&lt;P&gt;Thanks, so I'm trying to combine the two answers here - where would you put the lookup on this one?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 11:33:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263301#M50511</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-10-18T11:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263302#M50512</link>
      <description>&lt;P&gt;I wouldn't even bother about creating and maintaining a lookup to be honest. But that's my personal preference at least.&lt;/P&gt;

&lt;P&gt;If you want to filter just by specific slaves simply apply the filter (search or where) in the rest call inside the join. &lt;/P&gt;

&lt;P&gt;Of course a lookup is faster than running a rest query, but the difference is so tiny if the number of slaves is not huge (thousands) that I don't see too much benefit in having to create a lookup that you have to ensure is kept up-to-date.&lt;/P&gt;

&lt;P&gt;Hope that makes sense.&lt;/P&gt;

&lt;P&gt;If you give me more details on exactly what you are trying to filter on, I might be able to help more&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 11:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263302#M50512</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-18T11:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263303#M50513</link>
      <description>&lt;P&gt;Thanks.  We manage a license file for many different splunk (12) instances, so I like the idea of a lookup.  It allows me to easily separate the searches, knowing what is being reported on.  &lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 11:55:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263303#M50513</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-10-18T11:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Best place to filter out on field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263304#M50514</link>
      <description>&lt;P&gt;Since you asked about performance...&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Collapse those &lt;CODE&gt;rename&lt;/CODE&gt;s: &lt;CODE&gt;rename label as slave, title as i&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Collapse those &lt;CODE&gt;eval&lt;/CODE&gt;s: &lt;CODE&gt;eval indexname = if(len(idx)=0 OR isnull(idx),"(UNKNOWN)",idx), sourcetypename = st&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Looks like &lt;CODE&gt;sourcetypename&lt;/CODE&gt; is never used...so remove that?&lt;/LI&gt;
&lt;LI&gt;Alternate math: &lt;CODE&gt;eval GB=round( b pow( 1024, 3 ) , 3)&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;An alternate approach to this is a dashboard where an input field lists the indexers (use the guid as the value and the title as the label). That token(s) would get passed into the main panel where you run this search filtered by the selection.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 12:33:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-place-to-filter-out-on-field/m-p/263304#M50514</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-18T12:33:59Z</dc:date>
    </item>
  </channel>
</rss>

