<?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: Print searches with zero results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454625#M170550</link>
    <description>&lt;P&gt;I switched the join to append.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jul 2019 15:24:44 GMT</pubDate>
    <dc:creator>bandit</dc:creator>
    <dc:date>2019-07-05T15:24:44Z</dc:date>
    <item>
      <title>Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454618#M170543</link>
      <description>&lt;P&gt;I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ldap_csv |rename uid as user, extraced_host as host 
   | join user [search source=/var/log/secure   vendor_action="Accepted"
   | stats count as total_logins,  earliest(_time) as "first_login" latest(_time) as "last_login" by host user 
   |eval "first_login"=strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")
   |eval "last_login"=strftime(last_login, "%m/%d/%y - %I:%M:%S:%p") ] 
   |table user host  first_login last_login total_logins
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that returns exactly what I need except the results with zero total_logins.   I have read and tried a number of solutions, but can not get the results I need.  Any guidance here would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 20:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454618#M170543</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2019-07-02T20:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454619#M170544</link>
      <description>&lt;P&gt;Never use &lt;CODE&gt;join&lt;/CODE&gt;.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=ldap_csv) OR (index=YouShoulAlwaysSpecifyAnIndex AND sorucetype=AndSourcetypeToo AND source=/var/log/secure AND vendor_action="Accepted"
| eval user=if(index=="ldap_csv", uid, user)
| eval host=if(index=="ldap_csv", extraced_host, host)
| stats count AS total_logins,  min(_time) AS first_login max(_time) AS last_login BY host user index
| search index!="ldap_csv"
| fieldformat first_login = strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")
| fieldformat last_login = strftime(last_login, "%m/%d/%y - %I:%M:%S:%p")
| table user host first_login last_login total_logins
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 22:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454619#M170544</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-02T22:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454620#M170545</link>
      <description>&lt;P&gt;Append query that returns a list of all users &lt;/P&gt;

&lt;P&gt;something like this for your first query:&lt;BR /&gt;
all user query here | table user | eval total_logins=0&lt;BR /&gt;
| append [ search query with actual events ]&lt;BR /&gt;
| stats count AS total_logins,  min(_time) AS first_login max(_time) AS last_login BY host user index &lt;BR /&gt;
| eval count=count-1&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:10:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454620#M170545</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2020-09-30T01:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454621#M170546</link>
      <description>&lt;P&gt;I actually pasted the wrong search.  This is what I have:&lt;/P&gt;

&lt;P&gt;index="syslog_main" sourcetype=linux_secure  vendor_action="Accepted" &lt;BR /&gt;
[ search index=ldap_csv |fields uid extracted_host |rename uid as user, extracted_host as host ] &lt;BR /&gt;
| stats count as total_logins,  earliest(_time) as "first_login" latest(_time) as "last_login" by host user &lt;BR /&gt;
| eval "first_login"=strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
|eval "last_login"=strftime(last_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
| table user host first_login last_login total_logins&lt;/P&gt;

&lt;P&gt;I only want the users and hosts from the index=ldap_csv in my table, I also need to know when there are no entries in the index=syslog_main for those users.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454621#M170546</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2020-09-30T01:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454622#M170547</link>
      <description>&lt;P&gt;woodstock, I like your format, but the results are not what I am looking for.  I only want the table to contain the users and hosts from the index=ldap_csv.  Your results returned a concatenated table.  I also need to know when the the user/host does not have any entries in the syslog_main index.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454622#M170547</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2020-09-30T01:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454623#M170548</link>
      <description>&lt;P&gt;This is what I have now&lt;/P&gt;

&lt;P&gt;index="syslog_main"  sourcetype="linux_secure" vendor_action="Accepted" &lt;BR /&gt;
[ search index=ldap_csv |fields uid extracted_host |rename uid as user, extracted_host as host ]&lt;BR /&gt;
| stats count as total_logins,  earliest(_time) as "first_login" latest(_time) as "last_login" by host user &lt;BR /&gt;
| eval "first_login"=strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
|eval "last_login"=strftime(last_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
| table user host first_login last_login total_logins&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454623#M170548</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2020-09-30T01:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454624#M170549</link>
      <description>&lt;P&gt;I tried your suggestion.  I actually put the snippet in multiple places to see if I could get the 0 results, but I never got them.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 14:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454624#M170549</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2019-07-03T14:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454625#M170550</link>
      <description>&lt;P&gt;I switched the join to append.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 15:24:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454625#M170550</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2019-07-05T15:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454626#M170551</link>
      <description>&lt;P&gt;I was able to get the results I needed using:&lt;/P&gt;

&lt;P&gt;index=syslog_main sourcetype="linux_secure" vendor_action="Accepted" |stats count as found by user host |appendcols [search index="ldap_csv" |rename uid as user, extracted_host as host]|table user host found&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:14:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454626#M170551</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2020-09-30T01:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454627#M170552</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=ldap_csv) OR (index=YouShoulAlwaysSpecifyAnIndex AND sorucetype=AndSourcetypeToo AND source=/var/log/secure AND vendor_action="Accepted"
| eval user=if(index=="ldap_csv", uid, user)
| eval host=if(index=="ldap_csv", extraced_host, host)
| stats count AS total_logins,  min(_time) AS first_login max(_time) AS last_login dc(index) AS index_count values(index) AS indexes BY host user
| search indexes="ldap_csv"
| fieldformat first_login = strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")
| fieldformat last_login = strftime(last_login, "%m/%d/%y - %I:%M:%S:%p")
| table user host first_login last_login total_logins index_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jul 2019 22:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454627#M170552</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-05T22:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454628#M170553</link>
      <description>&lt;P&gt;See my new answer.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 22:36:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454628#M170553</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-05T22:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Print searches with zero results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454629#M170554</link>
      <description>&lt;P&gt;Thanks, with just a few modifications I have exactly what I was looking for.&lt;/P&gt;

&lt;P&gt;This is what I now have:&lt;/P&gt;

&lt;P&gt;(index=ldap_csv) OR (index=syslog_main AND sourcetype="linux_secure" AND source=/var/log/secure AND vendor_action="Accepted")&lt;BR /&gt;
 | eval user=if(index=="ldap_csv", uid, user)&lt;BR /&gt;
 | eval host=if(index=="ldap_csv", extracted_host, host)&lt;BR /&gt;
 | stats count AS total_logins,  min(_time) AS first_login max(_time) AS last_login dc(index) AS index_count values(index) AS indexes BY host user&lt;BR /&gt;
 | search indexes="ldap_csv"&lt;BR /&gt;
 | fieldformat first_login = strftime(first_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
 | fieldformat last_login = strftime(last_login, "%m/%d/%y - %I:%M:%S:%p")&lt;BR /&gt;
 | eval total_logins=total_logins-1&lt;BR /&gt;
 | eval first_login=if(first_login==last_login,"",first_login)&lt;BR /&gt;
 | eval last_login=if(first_login=="","",last_login)&lt;BR /&gt;
 | table user host first_login last_login total_logins index_count&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Print-searches-with-zero-results/m-p/454629#M170554</guid>
      <dc:creator>jfraley</dc:creator>
      <dc:date>2020-09-30T01:19:23Z</dc:date>
    </item>
  </channel>
</rss>

