<?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 How to count with inputlookup? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384358#M112251</link>
    <description>&lt;P&gt;Hi, I have a search that I have been struggle for a few days.&lt;/P&gt;

&lt;P&gt;I have an index that contains two fields: &lt;STRONG&gt;type&lt;/STRONG&gt; and &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;&lt;BR /&gt;
I have another CSV that contains similar fields: &lt;STRONG&gt;stype&lt;/STRONG&gt; and &lt;STRONG&gt;sTotal_Count&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Now the index may have many row with same &lt;STRONG&gt;type&lt;/STRONG&gt; and difference &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;, same on the CSV&lt;/P&gt;

&lt;P&gt;Purpose of the search is: for each row in index, find out how many row in CSV that have &lt;STRONG&gt;stype&lt;/STRONG&gt; is equal &lt;STRONG&gt;type&lt;/STRONG&gt;, and &lt;STRONG&gt;sTotal_Count&lt;/STRONG&gt; is greater than &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;, then append the count to the table along side with &lt;STRONG&gt;type&lt;/STRONG&gt; and &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;So I have test this inputlookup on CSV and it work fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup typeA.csv where stype="A01" and sTotal_Count &amp;gt; 30 | stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I would do something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ktme_v7_measurement"
| join
[|inputlookup typeA.csv where stype=type and sTotal_Count &amp;gt; Total_Count | stats count as type_c]
| table type Total_Count type_c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the &lt;STRONG&gt;type_c&lt;/STRONG&gt; column is always 0&lt;/P&gt;

&lt;P&gt;Then I found this question, he had same problem with me on passing field into subsearch&lt;/P&gt;

&lt;P&gt;answers/85076/passing-parent-data-into-subsearch.html&lt;/P&gt;

&lt;P&gt;but the answer was&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;an outer search cannot pass values into a subsearch&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And now I'm stuck, I'm very new to Splunk so I can not figure out how to do my search here.&lt;/P&gt;

&lt;P&gt;Please help me, many thanks&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2019 07:52:16 GMT</pubDate>
    <dc:creator>thanhnv244</dc:creator>
    <dc:date>2019-05-22T07:52:16Z</dc:date>
    <item>
      <title>How to count with inputlookup?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384358#M112251</link>
      <description>&lt;P&gt;Hi, I have a search that I have been struggle for a few days.&lt;/P&gt;

&lt;P&gt;I have an index that contains two fields: &lt;STRONG&gt;type&lt;/STRONG&gt; and &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;&lt;BR /&gt;
I have another CSV that contains similar fields: &lt;STRONG&gt;stype&lt;/STRONG&gt; and &lt;STRONG&gt;sTotal_Count&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Now the index may have many row with same &lt;STRONG&gt;type&lt;/STRONG&gt; and difference &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;, same on the CSV&lt;/P&gt;

&lt;P&gt;Purpose of the search is: for each row in index, find out how many row in CSV that have &lt;STRONG&gt;stype&lt;/STRONG&gt; is equal &lt;STRONG&gt;type&lt;/STRONG&gt;, and &lt;STRONG&gt;sTotal_Count&lt;/STRONG&gt; is greater than &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;, then append the count to the table along side with &lt;STRONG&gt;type&lt;/STRONG&gt; and &lt;STRONG&gt;Total_Count&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;So I have test this inputlookup on CSV and it work fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup typeA.csv where stype="A01" and sTotal_Count &amp;gt; 30 | stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I would do something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ktme_v7_measurement"
| join
[|inputlookup typeA.csv where stype=type and sTotal_Count &amp;gt; Total_Count | stats count as type_c]
| table type Total_Count type_c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the &lt;STRONG&gt;type_c&lt;/STRONG&gt; column is always 0&lt;/P&gt;

&lt;P&gt;Then I found this question, he had same problem with me on passing field into subsearch&lt;/P&gt;

&lt;P&gt;answers/85076/passing-parent-data-into-subsearch.html&lt;/P&gt;

&lt;P&gt;but the answer was&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;an outer search cannot pass values into a subsearch&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And now I'm stuck, I'm very new to Splunk so I can not figure out how to do my search here.&lt;/P&gt;

&lt;P&gt;Please help me, many thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 07:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384358#M112251</guid>
      <dc:creator>thanhnv244</dc:creator>
      <dc:date>2019-05-22T07:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to count with inputlookup?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384359#M112252</link>
      <description>&lt;P&gt;This requires getting creative with eventstats and multivalue functions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ktme_v7_measurement" 
| table type Total_Count
| streamstats count as rownum 
| append 
    [|inputlookup typeA.csv | rename stype as type | table stype sTotal_Count ] 
| eventstats list(sTotal_Count) as cvalues by type 
| search Total_Count=* 
| mvexpand cvalues 
| where cvalues&amp;gt;Total_Count 
| stats count by type,Total_Count,rownum 
| table type,Total_Count,count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gets the data from the index, keeps the 2 relevant columns and gives each row a unique number. This way the search also works when there are duplicate (type,Total_Count) entries in the index. It then adds the data from the lookup, renaming the stype field to type and again keeping only the relevant columns. It then lists all sTotal_Count values found for the same type. It then drops the rows originating from the lookup. It expands the multivalue field and then filters rows where the cvalue is greater than the Total_Count and then counts the entries by type,Total_count,rownum and finally drops the rownum and cvalues columns.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:41:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384359#M112252</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to count with inputlookup?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384360#M112253</link>
      <description>&lt;P&gt;Thank you very much, I think the result is perfect for me. The query seem overwhelming, I need to study it more.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 00:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384360#M112253</guid>
      <dc:creator>thanhnv244</dc:creator>
      <dc:date>2019-05-23T00:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to count with inputlookup?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384361#M112254</link>
      <description>&lt;P&gt;Feel free to drop a comment if you need further explanation. A good way to understand what it does, is just execute it step by step (possibly adding some filtering to reduce the number of rows, so it is easier to see what happens in each step).&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 08:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-with-inputlookup/m-p/384361#M112254</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-05-23T08:10:02Z</dc:date>
    </item>
  </channel>
</rss>

