<?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: How to use lookup to evaluate thresholds? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294022#M88758</link>
    <description>&lt;P&gt;Did not work out for me. Trying to troubleshoot. &lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2017 17:19:42 GMT</pubDate>
    <dc:creator>manmeet99</dc:creator>
    <dc:date>2017-03-28T17:19:42Z</dc:date>
    <item>
      <title>How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294017#M88753</link>
      <description>&lt;P&gt;Have been trying to crack this for a long time. Would highly appreciate any help. &lt;/P&gt;

&lt;P&gt;I have a lookup similar to this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Merchant_ID Amount_threshold  Count_threshold Description&lt;/STRONG&gt;&lt;BR /&gt;
Merchant1 15 1 ABC&lt;BR /&gt;
Merchant2 11 5 XYZ&lt;BR /&gt;
Merchant3 25 5 LMN&lt;BR /&gt;
*                  13 1 all_other_merchants&lt;/P&gt;

&lt;P&gt;And my events are:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Merchant_ID Amount&lt;/STRONG&gt;&lt;BR /&gt;
Merchant1 10&lt;BR /&gt;
Merchant1 20&lt;BR /&gt;
Merchant2 10&lt;BR /&gt;
Merchant3  40&lt;BR /&gt;
Merchant7 30&lt;BR /&gt;
Merchant7 20&lt;/P&gt;

&lt;P&gt;I want my query to return something like this:&lt;/P&gt;

&lt;P&gt;If for each merchant:&lt;/P&gt;

&lt;P&gt;Total_amount&amp;gt;amount_threshold AND count&amp;gt;count_threshold&lt;/P&gt;

&lt;P&gt;Then show it in the table below&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Merchant_ID Description Total_amount Total_count Amount_threshold Count_threshold&lt;/STRONG&gt;&lt;BR /&gt;
Merchant1 ABC 30 2 15 1&lt;BR /&gt;
Merchant7 all_other_merchants 50 2 13 1&lt;/P&gt;

&lt;P&gt;Update: Added a new case - a wild card merchant ID that captures all merchants not explicitly specified in the lookup and applies thresholds to that merchant. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:23:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294017#M88753</guid>
      <dc:creator>manmeet99</dc:creator>
      <dc:date>2020-09-29T13:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294018#M88754</link>
      <description>&lt;P&gt;Assuming the lookup file name is &lt;STRONG&gt;merchantlookup.csv&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt; 
| stats count as Total_count sum(Amount) as Total_amount by Merchant_ID 
| lookup merchantlookup MerchantID OUTPUT Amount_threshold Count_threshold Description
| where Total_amount&amp;gt;Amount_threshold AND Total_count &amp;gt;Count_threshold
| table MerchantID Description Total_amount Total_count Amount_threshold Count_threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Mar 2017 20:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294018#M88754</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-24T20:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294019#M88755</link>
      <description>&lt;P&gt;Use a left join against the lookup table, like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your event search) 
| stats count as Total_count sum(Amount) as Total_amount by Merchant_ID
| join type=left Merchant_ID
    [| inputlookup yourlookup.csv | table   Merchant_ID Amount_threshold Count_threshold Description ]
| where (Total_amount&amp;gt;Amount_threshold AND Total_count&amp;gt;Count_threshold) OR (isnull(Amount_threshold))
| fillnull value="((Not Found))" Description Amount_threshold Count_threshold
| table Merchant_ID  Description Total_amount Total_count Amount_threshold Count_threshold
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and here's some run-anywhere code to show you that it works...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults 
 | eval mydata="Merchant1,10 Merchant1,20 Merchant2,10 Merchant3,40 Merchant4,40" 
 | makemv mydata 
 | mvexpand mydata 
 | rex field=mydata "(?&amp;lt;Merchant_ID&amp;gt;[^,]+),(?&amp;lt;Amount&amp;gt;.*)"
 | stats count as Total_count sum(Amount) as Total_amount by Merchant_ID
 | join type=left Merchant_ID
     [| makeresults 
      | eval mylookup="Merchant1,15,1,ABC Merchant2,11,5,XYZ Merchant3,25,5,LMN" 
      | makemv mylookup 
      | mvexpand mylookup 
      | rex field=mylookup "(?&amp;lt;Merchant_ID&amp;gt;[^,]+),(?&amp;lt;Amount_threshold&amp;gt;[^,]+),(?&amp;lt;Count_threshold&amp;gt;[^,]+),(?&amp;lt;Description&amp;gt;.*)" 
      | table Merchant_ID Amount_threshold Count_threshold Description ]
 | where (Total_amount&amp;gt;Amount_threshold AND Total_count&amp;gt;Count_threshold) OR (isnull(Amount_threshold))
 | fillnull value="((Not Found))" Description Amount_threshold Count_threshold
 | table Merchant_ID  Description Total_amount Total_count Amount_threshold Count_threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Mar 2017 20:48:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294019#M88755</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-24T20:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294020#M88756</link>
      <description>&lt;P&gt;Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here | appendpipe [|inputlookup YourLookupHere]
| stats values(*) AS * sum(Amount) AS Total_amount count AS Total_count BY Merchant_ID
| where Total_amount&amp;gt;Amount_threshold AND Total_count&amp;gt;Count_threshold
| table Merchant_ID Description Total_amount Total_count Amount_threshold Count_threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2017 22:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294020#M88756</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-26T22:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294021#M88757</link>
      <description>&lt;P&gt;I tried this out. The threshold values display just one value for all rows instead of displaying threshold value applicable to the specific merchant. &lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 17:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294021#M88757</guid>
      <dc:creator>manmeet99</dc:creator>
      <dc:date>2017-03-28T17:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294022#M88758</link>
      <description>&lt;P&gt;Did not work out for me. Trying to troubleshoot. &lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 17:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294022#M88758</guid>
      <dc:creator>manmeet99</dc:creator>
      <dc:date>2017-03-28T17:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lookup to evaluate thresholds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294023#M88759</link>
      <description>&lt;P&gt;I tested and it works.  It may be that you have not described something in your dataset (probably a field name) accurately?  Double-check all the fieldnames and make sure that they match.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 19:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-lookup-to-evaluate-thresholds/m-p/294023#M88759</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-28T19:17:22Z</dc:date>
    </item>
  </channel>
</rss>

