<?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 Stats count by when field exists, otherwise use another in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470694#M132410</link>
    <description>&lt;P&gt;I am trying to create a dashboard that graphs the parsing queue size for a HF by &lt;CODE&gt;ingest_pipe&lt;/CODE&gt;.  I noticed that most of these logs have that field but some don't (i'm not sure why).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;sample logs&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;06-03-2020 12:21:30.964 -0400 INFO  Metrics - group=queue, name=parsingqueue, max_size_kb=512, current_size_kb=0, current_size=0, largest_size=2, smallest_size=0

06-03-2020 12:21:27.144 -0400 INFO  Metrics - group=queue, ingest_pipe=3, name=parsingqueue, max_size_kb=6144, current_size_kb=0, current_size=0, largest_size=2, smallest_size=0

06-03-2020 12:21:27.142 -0400 INFO  Metrics - group=queue, ingest_pipe=2, name=parsingqueue, max_size_kb=6144, current_size_kb=0, current_size=0, largest_size=11778, smallest_size=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;current SPL&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal host=$hostToken$ group=queue name=parsingqueue
| timechart avg(current_size_kb) by ingest_pipe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't modify the search with &lt;CODE&gt;ingest_pipe=*&lt;/CODE&gt; because I have tokenized the host field in the search and some of my HF's only have 1 ingest pipe.  In that scenario, there is no &lt;CODE&gt;ingest_pipe&lt;/CODE&gt; field at all so hardcoding that into the search will result in 0 results when the HF only has 1 pipeline.&lt;/P&gt;

&lt;P&gt;The solution I came up with is to count the # of events where ingest_pipe exists (yesPipe), count the # of events where it does not exist (noPipe), and assign my &lt;CODE&gt;count by foo&lt;/CODE&gt; value to the field that is greater.  If yesPipe is greater, &lt;CODE&gt;count by ingest_pipe&lt;/CODE&gt;, else &lt;CODE&gt;count by host&lt;/CODE&gt;.  I don't have the query for these counts and checks.&lt;/P&gt;

&lt;P&gt;Alternatively, I thought I could use a lookup table that has a "count by field" column, where per host I simply specify either &lt;CODE&gt;ingest_pipe&lt;/CODE&gt; or &lt;CODE&gt;host&lt;/CODE&gt; to count by.&lt;/P&gt;

&lt;P&gt;I feel like there is an easy solution and I'm overthinking it.  Any ideas?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:36:49 GMT</pubDate>
    <dc:creator>DEAD_BEEF</dc:creator>
    <dc:date>2020-09-30T05:36:49Z</dc:date>
    <item>
      <title>Stats count by when field exists, otherwise use another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470694#M132410</link>
      <description>&lt;P&gt;I am trying to create a dashboard that graphs the parsing queue size for a HF by &lt;CODE&gt;ingest_pipe&lt;/CODE&gt;.  I noticed that most of these logs have that field but some don't (i'm not sure why).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;sample logs&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;06-03-2020 12:21:30.964 -0400 INFO  Metrics - group=queue, name=parsingqueue, max_size_kb=512, current_size_kb=0, current_size=0, largest_size=2, smallest_size=0

06-03-2020 12:21:27.144 -0400 INFO  Metrics - group=queue, ingest_pipe=3, name=parsingqueue, max_size_kb=6144, current_size_kb=0, current_size=0, largest_size=2, smallest_size=0

06-03-2020 12:21:27.142 -0400 INFO  Metrics - group=queue, ingest_pipe=2, name=parsingqueue, max_size_kb=6144, current_size_kb=0, current_size=0, largest_size=11778, smallest_size=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;current SPL&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal host=$hostToken$ group=queue name=parsingqueue
| timechart avg(current_size_kb) by ingest_pipe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't modify the search with &lt;CODE&gt;ingest_pipe=*&lt;/CODE&gt; because I have tokenized the host field in the search and some of my HF's only have 1 ingest pipe.  In that scenario, there is no &lt;CODE&gt;ingest_pipe&lt;/CODE&gt; field at all so hardcoding that into the search will result in 0 results when the HF only has 1 pipeline.&lt;/P&gt;

&lt;P&gt;The solution I came up with is to count the # of events where ingest_pipe exists (yesPipe), count the # of events where it does not exist (noPipe), and assign my &lt;CODE&gt;count by foo&lt;/CODE&gt; value to the field that is greater.  If yesPipe is greater, &lt;CODE&gt;count by ingest_pipe&lt;/CODE&gt;, else &lt;CODE&gt;count by host&lt;/CODE&gt;.  I don't have the query for these counts and checks.&lt;/P&gt;

&lt;P&gt;Alternatively, I thought I could use a lookup table that has a "count by field" column, where per host I simply specify either &lt;CODE&gt;ingest_pipe&lt;/CODE&gt; or &lt;CODE&gt;host&lt;/CODE&gt; to count by.&lt;/P&gt;

&lt;P&gt;I feel like there is an easy solution and I'm overthinking it.  Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470694#M132410</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2020-09-30T05:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count by when field exists, otherwise use another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470695#M132411</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;fillnull&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal host=$hostToken$ group=queue name=parsingqueue
| fillnull value=0 ingest_pipe
| timechart avg(current_size_kb) by ingest_pipe
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 17:48:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470695#M132411</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T17:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count by when field exists, otherwise use another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470696#M132412</link>
      <description>&lt;P&gt;So when ingest_pipe is not there, it gives it a value of 0, and when it is present, it does nothing?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 18:42:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470696#M132412</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2020-06-03T18:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count by when field exists, otherwise use another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470697#M132413</link>
      <description>&lt;P&gt;That is what &lt;CODE&gt;fillnull&lt;/CODE&gt; does, yes.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 20:22:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-by-when-field-exists-otherwise-use-another/m-p/470697#M132413</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T20:22:20Z</dc:date>
    </item>
  </channel>
</rss>

