<?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 Help needed with a search and a lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-needed-with-a-search-and-a-lookup/m-p/292572#M88314</link>
    <description>&lt;P&gt;All,&lt;/P&gt;

&lt;P&gt;I have this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ssn sourcetype="agent" 
| rex field=_raw "Files:(?&amp;lt;customer&amp;gt;.*):/tmp/(?&amp;lt;filepath&amp;gt;.*):(?&amp;lt;filecount&amp;gt;.*)"  | stats sum(filecount) as filecount by customer host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It returns this data:&lt;/P&gt;

&lt;P&gt;1   CUST001     host001     782&lt;BR /&gt;
2   CUST002     host002     150&lt;BR /&gt;
3   CUST003     host003     10&lt;BR /&gt;
4   CUST004     host004     15&lt;BR /&gt;
5   CUST005     host005     3&lt;BR /&gt;
6   CUST006     host006     44&lt;BR /&gt;
7   CUST007     host007     997&lt;BR /&gt;
8   CUST008     host008 87&lt;BR /&gt;
9   CUST009     host009     3587&lt;BR /&gt;
10  CUST010     host010     18&lt;BR /&gt;
11  CUST011     host011     273&lt;BR /&gt;
12  CUST012     host012     20227&lt;BR /&gt;
13  CUST013     host001     18&lt;/P&gt;

&lt;P&gt;I need one alarm for hosts that are in a lookup table AND the filecount is 0. The lookup table is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sldp-oo_customers

1   host001     CUST001
2   host001     CUST001
3   host001     CUST001
4   host020     CUST020
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output I need is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1   CUST020     host020     0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you may notice, the host in question does not have result in the first search, in this case it is missing data, but I want to be able to change the threshold (0 files) if needed.&lt;/P&gt;

&lt;P&gt;The only way I found to achieve this result is to run it in 2 searches:&lt;/P&gt;

&lt;P&gt;1) Generate another lookup file with the result of first search and schedule to run minutes before the second one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=ssn sourcetype="agent" 
| rex field=_raw "Files:(?&amp;lt;customer&amp;gt;.*):/tmp/(?&amp;lt;filepath&amp;gt;.*):(?&amp;lt;filecount&amp;gt;.*)"  | stats sum(filecount) as filecount by customer host | outputlookup sldp-oo-filecount.csv createinapp=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) Run search using 2 lookup tables:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sldp-oo_customers | lookup sldp-oo-filecount.csv customer as customer host as host OUTPUT filecount | fillnull value=0 filecount | search filecount=0 | fields customer host filecount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a better way to do this? Today is fine because the user want it to run every 24h, but it may became nightmare if I need to run it often.&lt;/P&gt;

&lt;P&gt;Thank you very much for your help,&lt;/P&gt;

&lt;P&gt;Gerson&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 16:21:49 GMT</pubDate>
    <dc:creator>GersonGarcia</dc:creator>
    <dc:date>2017-10-10T16:21:49Z</dc:date>
    <item>
      <title>Help needed with a search and a lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-needed-with-a-search-and-a-lookup/m-p/292572#M88314</link>
      <description>&lt;P&gt;All,&lt;/P&gt;

&lt;P&gt;I have this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ssn sourcetype="agent" 
| rex field=_raw "Files:(?&amp;lt;customer&amp;gt;.*):/tmp/(?&amp;lt;filepath&amp;gt;.*):(?&amp;lt;filecount&amp;gt;.*)"  | stats sum(filecount) as filecount by customer host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It returns this data:&lt;/P&gt;

&lt;P&gt;1   CUST001     host001     782&lt;BR /&gt;
2   CUST002     host002     150&lt;BR /&gt;
3   CUST003     host003     10&lt;BR /&gt;
4   CUST004     host004     15&lt;BR /&gt;
5   CUST005     host005     3&lt;BR /&gt;
6   CUST006     host006     44&lt;BR /&gt;
7   CUST007     host007     997&lt;BR /&gt;
8   CUST008     host008 87&lt;BR /&gt;
9   CUST009     host009     3587&lt;BR /&gt;
10  CUST010     host010     18&lt;BR /&gt;
11  CUST011     host011     273&lt;BR /&gt;
12  CUST012     host012     20227&lt;BR /&gt;
13  CUST013     host001     18&lt;/P&gt;

&lt;P&gt;I need one alarm for hosts that are in a lookup table AND the filecount is 0. The lookup table is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sldp-oo_customers

1   host001     CUST001
2   host001     CUST001
3   host001     CUST001
4   host020     CUST020
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output I need is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1   CUST020     host020     0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you may notice, the host in question does not have result in the first search, in this case it is missing data, but I want to be able to change the threshold (0 files) if needed.&lt;/P&gt;

&lt;P&gt;The only way I found to achieve this result is to run it in 2 searches:&lt;/P&gt;

&lt;P&gt;1) Generate another lookup file with the result of first search and schedule to run minutes before the second one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=ssn sourcetype="agent" 
| rex field=_raw "Files:(?&amp;lt;customer&amp;gt;.*):/tmp/(?&amp;lt;filepath&amp;gt;.*):(?&amp;lt;filecount&amp;gt;.*)"  | stats sum(filecount) as filecount by customer host | outputlookup sldp-oo-filecount.csv createinapp=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) Run search using 2 lookup tables:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sldp-oo_customers | lookup sldp-oo-filecount.csv customer as customer host as host OUTPUT filecount | fillnull value=0 filecount | search filecount=0 | fields customer host filecount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a better way to do this? Today is fine because the user want it to run every 24h, but it may became nightmare if I need to run it often.&lt;/P&gt;

&lt;P&gt;Thank you very much for your help,&lt;/P&gt;

&lt;P&gt;Gerson&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 16:21:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-needed-with-a-search-and-a-lookup/m-p/292572#M88314</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-10-10T16:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with a search and a lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-needed-with-a-search-and-a-lookup/m-p/292573#M88315</link>
      <description>&lt;P&gt;You can use append command to concatenate results from your search and lookup.&lt;/P&gt;

&lt;P&gt;Like this..&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=ssn sourcetype="agent" &lt;BR /&gt;
 | rex field=_raw "Files:(?.*):/tmp/(?.*):(?.*)"  | stats sum(filecount) as filecount by customer host | append [| inputlookup sldp-oo_customers] | stats values(*) as * by host | fillnull value=0 | where filecount=0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;make sure the host fieldname in lookup is also host, otherwise rename it to host in second query&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 22:41:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-needed-with-a-search-and-a-lookup/m-p/292573#M88315</guid>
      <dc:creator>kyaparla</dc:creator>
      <dc:date>2017-10-10T22:41:09Z</dc:date>
    </item>
  </channel>
</rss>

