<?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 find the number of hosts that never reported to splunk from a lookup with the existing query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331040#M98541</link>
    <description>&lt;P&gt;Hmm...I could imagine this being caused by a case mis-match (lower-case vs. upper-case) across entries in the lookup table and values in the log entries. Let's try a revision with hosts converted all to lower-case. I'll update the original post with a conversion case.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 20:21:58 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2017-10-23T20:21:58Z</dc:date>
    <item>
      <title>how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331028#M98529</link>
      <description>&lt;P&gt;I have a query as follows to display the list of hosts which are seen in last 24 hours and hosts which are not seen in last 24 hours from a list of lookup table hosts. which is working fine. But I also want to see the list of hosts which are neither seen in last 24 hours nor not seen in 24 hours. I mean the hosts which are never in splunk &lt;/P&gt;

&lt;P&gt;The following is my query &lt;/P&gt;

&lt;P&gt;| metadata type=hosts  | search [| inputlookup hosts_test.csv | search environment="PROD" | rename my_hostname as host | eval host=lower(host) | eval recentTime=0&lt;BR /&gt;
       | table host] &lt;BR /&gt;
  | eval lastTime=coalesce(lastTime,0)&lt;BR /&gt;
  | eval timeDiff=now()-lastTime&lt;BR /&gt;
  | eval last_seen_in_24_hours=case(timeDiff==NULL, "never in Splunk", timeDiff&amp;gt;86400,"Systems not reported to Splunk from last 24 hours", 1==1,"Systems reported to Splunk in last 24 hours")&lt;BR /&gt;
  | eval lastReported=if(lastTime=0,"never",strftime(lastTime,"%F %T")) &lt;/P&gt;

&lt;P&gt;Following is the result :-&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/219577-hosts.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Now I also want to see the remaining hosts which are never in splunk as "never in splunk". I'm trying to display the number for never seen hosts in the report along with last seen in 24 hours and not seen in 24 hours like below &lt;/P&gt;

&lt;P&gt;last_seen_in_24_hours&lt;BR /&gt;
systems not reported to splunk in last 24 hours                                43&lt;BR /&gt;
systems reported to splunk in last 24 hours                                       768&lt;BR /&gt;
systems never reported to splunk                                                         76&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331028#M98529</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T16:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331029#M98530</link>
      <description>&lt;P&gt;I think this should do it:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| metadata type=hosts | search [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname) | fields host ] | append [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname)  | eval recentTime=0, lastTime=0 | fields host recentTime lastTime ] | dedup host | eval category=case(recentTime&amp;gt;=relative_time(now(), "-24h"), "Systems reported to Splunk in last 24 hours", (recentTime&amp;lt;relative_time(now(), "-24h") AND recentTime&amp;gt;0), "Systems reported to Splunk more than 24 hours ago", recentTime=0, "Systems never reported to Splunk") | stats dc(host) as "Total Hosts" BY category&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Note that your approach with applying "lastTime=0" in the inputlookup portion of your original search was having no effect - by feeding the data from the inputlookup directly into a search, Splunk was discarding all the hosts that weren't found. I added a second inputlookup inside an append command, and then I applied &lt;CODE&gt;dedup&lt;/CODE&gt; to remove the hosts that had been found.&lt;/P&gt;

&lt;P&gt;If there is any chance that the hostnames in your csv file have different capitalization than the values in the log entries, this conversion might be necessary:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| metadata type=hosts | search [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname) | fields host ] | eval host=lower(host) | append [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname)  | eval recentTime=0, lastTime=0, host=lower(host) | fields host recentTime lastTime ] | dedup host | eval category=case(recentTime&amp;gt;=relative_time(now(), "-24h"), "Systems reported to Splunk in last 24 hours", (recentTime&amp;lt;relative_time(now(), "-24h") AND recentTime&amp;gt;0), "Systems reported to Splunk more than 24 hours ago", recentTime=0, "Systems never reported to Splunk") | stats dc(host) as "Total Hosts" BY category&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 18:58:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331029#M98530</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T18:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331030#M98531</link>
      <description>&lt;P&gt;I meant to mention: it might be helpful to consult the docs for metadata to determine if you really want to use &lt;CODE&gt;lastTime&lt;/CODE&gt; or if &lt;CODE&gt;recentTime&lt;/CODE&gt; is more appropriate for your use case:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Metadata"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Metadata&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;My search uses recentTime, because that references the last &lt;CODE&gt;indextime&lt;/CODE&gt; of an event from the particular host, which seemed most useful for determining when a host actually last contacted Splunk. But if &lt;CODE&gt;lastTime&lt;/CODE&gt; really is best for your use case, replace &lt;CODE&gt;recentTime&lt;/CODE&gt; with &lt;CODE&gt;lastTime&lt;/CODE&gt; in the last portion of my code above.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331030#M98531</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T19:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331031#M98532</link>
      <description>&lt;P&gt;Thanks for the quick response @elliotproebstel. I still see the result displays only 2 field values and no results for "Systems never reported to splunk" looks like Splunk was still discarding all the hosts that weren't found.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331031#M98532</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T19:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331032#M98533</link>
      <description>&lt;P&gt;Oops! Yes, there is a cut and paste error in my code. I'm going to fix it above - but the issue is the extra pipe after &lt;CODE&gt;append&lt;/CODE&gt;. Sorry.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:10:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331032#M98533</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T19:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331033#M98534</link>
      <description>&lt;P&gt;No issues. I corrected that. Please find my updated responce. :).&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:13:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331033#M98534</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T19:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331034#M98535</link>
      <description>&lt;P&gt;Ahhh, I'm sorry for all the back and forth. I forgot to apply the conversion on the second &lt;CODE&gt;inputlookup&lt;/CODE&gt;. Will fix now.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:25:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331034#M98535</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T19:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331035#M98536</link>
      <description>&lt;P&gt;Great. Thanks a lot for your time. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:27:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331035#M98536</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T19:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331036#M98537</link>
      <description>&lt;P&gt;By not converting &lt;CODE&gt;my_hostname&lt;/CODE&gt; to &lt;CODE&gt;host&lt;/CODE&gt; in the subsearch, the &lt;CODE&gt;inputlookup&lt;/CODE&gt; was appending nothing to the parent search. Sorry! Should be fixed now.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:27:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331036#M98537</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T19:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331037#M98538</link>
      <description>&lt;P&gt;Hi @elliotproebstel still no change. Only 2 values are displaying and no "Systems never reported to Splunk"&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:38:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331037#M98538</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T19:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331038#M98539</link>
      <description>&lt;P&gt;Hmm...Try this code and see if there are any hosts with &lt;CODE&gt;recentTime=0&lt;/CODE&gt; and &lt;CODE&gt;lastTime=0&lt;/CODE&gt;: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| metadata type=hosts | search [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname) | fields host ] | append [| inputlookup mssp_dashboard_hosts_test.csv | search hpam_environment="PROD" | eval host=lower(my_hostname) | eval recentTime=0, lastTime=0 | fields host recentTime lastTime ] | dedup host&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If not, are you certain there are any hosts in mssp_dashboard_hosts_test.csv with &lt;CODE&gt;hpam_environment="PROD"&lt;/CODE&gt; that have never reported to Splunk?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:27:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331038#M98539</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T16:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331039#M98540</link>
      <description>&lt;P&gt;Hi @elliotproebstel It worked and displayed the results as follows &lt;/P&gt;

&lt;P&gt;category    Total Hosts&lt;BR /&gt;
Systems never reported to Splunk    402&lt;BR /&gt;
Systems reported to Splunk in last 24 hours 966&lt;BR /&gt;
Systems reported to Splunk more than 24 hours ago   21&lt;/P&gt;

&lt;P&gt;But the total number of hosts in the lookup is 1066. which means the Systems never reported to Splunk shoul be 1066-(966+21)=79. But here the 79 count has been displayed as 402 looks like something wrong with the calculation.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 20:09:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331039#M98540</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T20:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331040#M98541</link>
      <description>&lt;P&gt;Hmm...I could imagine this being caused by a case mis-match (lower-case vs. upper-case) across entries in the lookup table and values in the log entries. Let's try a revision with hosts converted all to lower-case. I'll update the original post with a conversion case.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 20:21:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331040#M98541</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T20:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331041#M98542</link>
      <description>&lt;P&gt;great worked now. Thank you &lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 20:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331041#M98542</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2017-10-23T20:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the number of hosts that never reported to splunk from a lookup with the existing query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331042#M98543</link>
      <description>&lt;P&gt;Glad I could help!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 20:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-the-number-of-hosts-that-never-reported-to-splunk/m-p/331042#M98543</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T20:59:02Z</dc:date>
    </item>
  </channel>
</rss>

