<?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 Default value for `stats count` or `top` in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463983#M130796</link>
    <description>&lt;P&gt;This should be a trivial thing, but I'm having a hard time figuring out how to do it in Splunk: how do I use a default value for a key?&lt;/P&gt;

&lt;P&gt;Here's an example: suppose I'm interested in HTTP status codes, so I do something like&lt;BR /&gt;
 &lt;CODE&gt;&lt;BR /&gt;
index=whatever "HTTP/1.1"&lt;BR /&gt;
| top status_code&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
If there are no 5xx errors, I'd like this to return "0%"; otherwise, return the % of 5xx errors.&lt;/P&gt;

&lt;P&gt;This should be trivial no?&lt;/P&gt;

&lt;P&gt;In SQL, I guess the way I'd do this is to have some table on the left side of a join, containing every possible HTTP status code. Then &lt;CODE&gt;LEFT OUTER JOIN&lt;/CODE&gt; to a table that generates actual percentages by error code, and use &lt;CODE&gt;COALESCE()&lt;/CODE&gt; to return a zero if there's nothing on the right side corresponding to that status code. What's the Splunk equivalent?&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2019 18:05:31 GMT</pubDate>
    <dc:creator>shulmaniel</dc:creator>
    <dc:date>2019-08-26T18:05:31Z</dc:date>
    <item>
      <title>Default value for `stats count` or `top`</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463983#M130796</link>
      <description>&lt;P&gt;This should be a trivial thing, but I'm having a hard time figuring out how to do it in Splunk: how do I use a default value for a key?&lt;/P&gt;

&lt;P&gt;Here's an example: suppose I'm interested in HTTP status codes, so I do something like&lt;BR /&gt;
 &lt;CODE&gt;&lt;BR /&gt;
index=whatever "HTTP/1.1"&lt;BR /&gt;
| top status_code&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
If there are no 5xx errors, I'd like this to return "0%"; otherwise, return the % of 5xx errors.&lt;/P&gt;

&lt;P&gt;This should be trivial no?&lt;/P&gt;

&lt;P&gt;In SQL, I guess the way I'd do this is to have some table on the left side of a join, containing every possible HTTP status code. Then &lt;CODE&gt;LEFT OUTER JOIN&lt;/CODE&gt; to a table that generates actual percentages by error code, and use &lt;CODE&gt;COALESCE()&lt;/CODE&gt; to return a zero if there's nothing on the right side corresponding to that status code. What's the Splunk equivalent?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:05:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463983#M130796</guid>
      <dc:creator>shulmaniel</dc:creator>
      <dc:date>2019-08-26T18:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Default value for `stats count` or `top`</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463984#M130797</link>
      <description>&lt;P&gt;You can do the same in Splunk by creating a lookup table that contains all the HTTP code you are interested in. &lt;/P&gt;

&lt;P&gt;index=whatever "HTTP/1.1"&lt;BR /&gt;
| stats count by status_code&lt;BR /&gt;
| inputlookup YourLookupFile &lt;BR /&gt;
| stats sum(count) as count by status_code&lt;BR /&gt;
| fillnull value=0 count&lt;/P&gt;

&lt;P&gt;The end results, will be a list of all status_codes with their counts, code with no count will show 0&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:55:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463984#M130797</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2020-09-30T01:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Default value for `stats count` or `top`</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463985#M130798</link>
      <description>&lt;P&gt;This is the &lt;CODE&gt;Sentinel Search&lt;/CODE&gt; problem discussed (with solution) here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf"&gt;https://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463985#M130798</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-26T18:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Default value for `stats count` or `top`</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463986#M130799</link>
      <description>&lt;P&gt;This may help you to convert your sql query to spl.&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/SQLtoSplunk"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:30:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-value-for-stats-count-or-top/m-p/463986#M130799</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-26T18:30:30Z</dc:date>
    </item>
  </channel>
</rss>

