<?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 display source which not getting any hits in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325661#M60534</link>
    <description>&lt;P&gt;i have different source and want to display source which not getting any hits&lt;/P&gt;

&lt;P&gt;I have the following query&lt;/P&gt;

&lt;P&gt;source=ABC OR source=ABD OR source=ADC | stats count by source&lt;/P&gt;

&lt;P&gt;time frame: last 1 day&lt;/P&gt;

&lt;P&gt;i need the result like this&lt;/P&gt;

&lt;P&gt;Source             count&lt;BR /&gt;
ADC                    0&lt;/P&gt;</description>
    <pubDate>Tue, 10 Apr 2018 13:18:59 GMT</pubDate>
    <dc:creator>logloganathan</dc:creator>
    <dc:date>2018-04-10T13:18:59Z</dc:date>
    <item>
      <title>display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325661#M60534</link>
      <description>&lt;P&gt;i have different source and want to display source which not getting any hits&lt;/P&gt;

&lt;P&gt;I have the following query&lt;/P&gt;

&lt;P&gt;source=ABC OR source=ABD OR source=ADC | stats count by source&lt;/P&gt;

&lt;P&gt;time frame: last 1 day&lt;/P&gt;

&lt;P&gt;i need the result like this&lt;/P&gt;

&lt;P&gt;Source             count&lt;BR /&gt;
ADC                    0&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:18:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325661#M60534</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-10T13:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325662#M60535</link>
      <description>&lt;P&gt;This is how I do it&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count 
| eval source="ABC,ABD,ADC" 
| makemv delim="," source 
| mvexpand source 
| append 
    [ search source=ABC OR source=ABD OR source=ADC ] 
| stats sum(eval(if(isnull(_time),0,1))) as count by source 
| where count = 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:23:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325662#M60535</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-04-10T13:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325663#M60536</link>
      <description>&lt;P&gt;i am getting different value..actually i am doing for last 1 day..Could you please modify according to that&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325663#M60536</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-10T13:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325664#M60537</link>
      <description>&lt;P&gt;there's no time specified in the search so just change your time picker to last 1 day. &lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325664#M60537</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-04-10T13:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325665#M60538</link>
      <description>&lt;P&gt;it giving me three values but i have only one. &lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:48:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325665#M60538</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-10T13:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325666#M60539</link>
      <description>&lt;P&gt;It's giving you three zero values? &lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325666#M60539</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-04-10T13:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325667#M60540</link>
      <description>&lt;P&gt;yes kmaron &lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 15:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325667#M60540</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-10T15:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325668#M60541</link>
      <description>&lt;P&gt;@logloganathan do these three sources write data to same sourcetype or different? Also is the index same for these sources or different?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 15:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325668#M60541</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-10T15:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325669#M60542</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[UPDATED ANSWER]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The following search should give 0 count for a sourcetype with no events. Run anywhere example from Splunk's _internal index is also added for testing. A very small time window should be picked to ensure that there is no event from specific source to test.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  tstats count where index="&amp;lt;yourIndexName&amp;gt;" AND (source="ABC" OR source="ABD" OR source="ADC") by source
|  append [ | makeresults
                   | fields - _time 
                   | eval source="ABC,ABD,ADC"
                   | makemv source delim=","
                   | mvexpand source
                   | eval count=0 ]
|  dedup source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on Splunk's _internal index (since it always writes time window should be really small like &lt;CODE&gt;last 5 seconds&lt;/CODE&gt; to get 0 event count).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=_internal AND (sourcetype="splunk_web_access" OR sourcetype="splunkd_ui_access" OR sourcetype="splunkd") by sourcetype 
| append 
    [| makeresults 
    | fields - _time 
    | eval sourcetype="splunk_web_access,splunkd_ui_access,splunkd" 
    | makemv sourcetype delim="," 
    | mvexpand sourcetype 
    | eval count=0]
| dedup sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;@logloganathan, for scenario like these where you have to perform stats on metadata fields, ideally &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Tstats"&gt;tstats&lt;/A&gt; or &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Metadata"&gt;metadata&lt;/A&gt; command should be used. Following is a run anywhere search based on Splunk's _internal index for three source patterns. Please try out and adjust as per your need.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  tstats count as totalCount earliest(_time) as earliestEventTime latest(_time) as _time where index="_*" AND (source="*kvstore.log" OR source="*metrics.log" OR source="*license_usage_summary.log") by source
|  fieldformat earliestEventTime=strftime(earliestEventTime,"%Y-%m-%d %H:%M:%S")
|  reltime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Reltime"&gt;reltime&lt;/A&gt; command applies on _time field (which in this case is last time event was written on specific source), to give the relative time.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 15:38:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325669#M60542</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-10T15:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325670#M60543</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;If you try by this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=ABC OR source=ABD OR source=ADC daysago=1  | stats count by source | where count=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2018 16:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325670#M60543</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-10T16:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325671#M60544</link>
      <description>&lt;P&gt;@Nikenilay,&lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;

&lt;P&gt;i want to display the source which as count value as zero&lt;/P&gt;

&lt;P&gt;your query not helping&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325671#M60544</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-11T15:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325672#M60545</link>
      <description>&lt;P&gt;thanks for your help.&lt;/P&gt;

&lt;P&gt;it displaying "no result"&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325672#M60545</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-11T15:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325673#M60546</link>
      <description>&lt;P&gt;its having same sourcetype and same index&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:22:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325673#M60546</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-11T15:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325674#M60547</link>
      <description>&lt;P&gt;if it displaying "no result" because all count are &amp;gt; 0 try by where &lt;CODE&gt;count!=0&lt;/CODE&gt; to verified&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325674#M60547</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-11T15:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325675#M60548</link>
      <description>&lt;P&gt;My Previous query was for you to test out and understand the working of tstats command with run anywhere example. For getting the count by source as 0, you need to add the following filter in the end &lt;CODE&gt;| search totalCount=0&lt;/CODE&gt; and also provide your index name &lt;CODE&gt;index="&amp;lt;yourIndexName&amp;gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |  tstats count as totalCount earliest(_time) as earliestEventTime latest(_time) as _time where index="&amp;lt;yourIndexName&amp;gt;" AND (source="ABC" OR source="ABD" OR source="ADC") by source
 |  fieldformat earliestEventTime=strftime(earliestEventTime,"%Y-%m-%d %H:%M:%S")
 |  reltime
 | search totalCount=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325675#M60548</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-11T15:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325676#M60549</link>
      <description>&lt;P&gt;i have provided my index name in the query but it displaying "no result" now&lt;/P&gt;

&lt;P&gt;earlier query produced the result of two source with some value&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:40:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325676#M60549</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-11T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325677#M60550</link>
      <description>&lt;P&gt;No Results means there is not source with 0 count. Take out final &lt;CODE&gt;search totalCount=0&lt;/CODE&gt;, you will see how many events you have received in last 1 day. Also when was first event and last event received from the source in last 1 day.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:48:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325677#M60550</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-11T15:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325678#M60551</link>
      <description>&lt;P&gt;while take out it displaying two sources &lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 15:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325678#M60551</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-11T15:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325679#M60552</link>
      <description>&lt;P&gt;@logloganathan, I have updated the answer to reflect 0 count in case the source does not have any event for selected time duration. Test with smaller duration to confirm 0 count before switching to last 1 day.&lt;/P&gt;

&lt;P&gt;Please try out and confirm.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 20:00:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325679#M60552</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-11T20:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: display source which not getting any hits</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325680#M60553</link>
      <description>&lt;P&gt;Thanks for your help!! &lt;BR /&gt;
yes..its working but small correction we have to add | where count=0&lt;BR /&gt;
Final Query:&lt;BR /&gt;
|  tstats count where index="" AND (source="ABC" OR source="ABD" OR source="ADC") by source&lt;BR /&gt;
 |  append [ | makeresults&lt;BR /&gt;
                    | fields - _time &lt;BR /&gt;
                    | eval source="ABC,ABD,ADC"&lt;BR /&gt;
                    | makemv source delim=","&lt;BR /&gt;
                    | mvexpand source&lt;BR /&gt;
                    | eval count=0 ]&lt;BR /&gt;
 |  dedup source | where count=0&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 08:37:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/display-source-which-not-getting-any-hits/m-p/325680#M60553</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-04-12T08:37:30Z</dc:date>
    </item>
  </channel>
</rss>

