<?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: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236459#M70235</link>
    <description>&lt;P&gt;Try &lt;CODE&gt;coalesce&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval source=coalesce(source, "N/A")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=coalesce(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, "n/a")]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Aug 2016 19:55:02 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-08-23T19:55:02Z</dc:date>
    <item>
      <title>Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236458#M70234</link>
      <description>&lt;P&gt;Hello Splunk experts,&lt;/P&gt;

&lt;P&gt;Hoping someone can help get me in the right path.  I am running a search where I would like to default values when certain sourcetypes do not return events.  For the sake of an example I'll use tstats &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats latest(_time) WHERE index=* (sourcetype=source1 OR sourcetype=source2 OR sourcetype=source3) by index host sourcetype |table host, sourcetype, latest(_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, how can I force or create an N/A value when any of the defined sourcetypes in my search do not return any events?  ie; let's say I have events for the source1 and source2, but no results come back for source3.  Is there a way to default a value or better way to approach this?  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host1   source1  1471968565
host2   source2  1471968565
N/A     source3  N/A
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for the help&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236458#M70234</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-08-23T19:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236459#M70235</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;coalesce&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval source=coalesce(source, "N/A")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=coalesce(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, "n/a")]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:55:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236459#M70235</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-23T19:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236460#M70236</link>
      <description>&lt;P&gt;Couldn't get either to work. I thought coalesce takes the first non-null value?  Would it work in this case since nothing in theory would be coming back?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236460#M70236</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-08-23T20:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236461#M70237</link>
      <description>&lt;P&gt;How about forcing a row of "n/a"?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats latest(_time) as time WHERE index=* (sourcetype=source1 OR sourcetype=source2) by index host sourcetype | table host, sourcetype, time | foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=coalesce(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, "n/a")] | append [| makeresults | eval host="n/a" | eval sourcetype="n/a" | eval time="n/a" | fields - _time]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236461#M70237</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-23T20:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236462#M70238</link>
      <description>&lt;P&gt;Why can't fillnull be an option?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 12:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236462#M70238</guid>
      <dc:creator>sheamus69</dc:creator>
      <dc:date>2016-08-24T12:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236463#M70239</link>
      <description>&lt;P&gt;b/c it doesn't do anything in this case.  Unless I am using it incorrectly it just doesn't force a value&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 17:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236463#M70239</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-08-29T17:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236464#M70240</link>
      <description>&lt;P&gt;sundareshr, thanks for the follow up reply.  &lt;/P&gt;

&lt;P&gt;Closer, but still not what I am looking for.  The problem is that it doesn't tell me which of my defined sourcetypes in my WHERE statement are missing, I just get an n/a.  So in this case i get something like below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host         sourcetype        time
host1       source1              11:00:00
n/a          n/a               n/a
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I would like something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host         sourcetype        time
host1       source1              11:00:00
n/a           source2            n/a
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Aug 2016 17:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236464#M70240</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-08-29T17:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236465#M70241</link>
      <description>&lt;P&gt;When you're looking for a result event when there is truly &lt;EM&gt;nothing&lt;/EM&gt; then there really isn't a built-in search command that will make something from nothing.  An approach that @starcher and I have talked about in past .conf talks was to use the concept of a 'sentinel row' coming from a lookup table, like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats max(_time) as maxtime WHERE 
      index=* (sourcetype=source1 OR sourcetype=source2 OR sourcetype=source3) 
      by index host sourcetype 
| inputlookup append=true source_sentinels.csv
| stats max(maxtime) as maxtime by index host sourcetype
| outputlookup source_sentinels.csv
| table host, sourcetype, maxtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The main point here is that your lookup file contains placeholders for the results that might not be in the results returned by the search.  What we do here is use an &lt;CODE&gt;inputlookup&lt;/CODE&gt; followed by a 2nd call to stats to take either the value from &lt;CODE&gt;tstats&lt;/CODE&gt; OR the value from the lookup.  For good measure, we re-output-lookup the lookup file so that any new sourcetypes you add get more-or-less handled.&lt;/P&gt;

&lt;P&gt;You can see the slides and audio/video where we discuss this at &lt;A href="http://conf.splunk.com/session/2015/recordings/2015-splunk-38.mp4"&gt;http://conf.splunk.com/session/2015/recordings/2015-splunk-38.mp4&lt;/A&gt; or &lt;A href="http://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf"&gt;http://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 05:40:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236465#M70241</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-08-30T05:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Without using fillnull, how to output a default value when any defined sourcetypes in my search do not return any events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236466#M70242</link>
      <description>&lt;P&gt;Fillnull is great when you have results that are missing values.  But, when the whole "result row" is missing because the search did not return anything for it, fillnull cannot make new result rows out of nothingness..&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:44:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Without-using-fillnull-how-to-output-a-default-value-when-any/m-p/236466#M70242</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-08-30T18:44:41Z</dc:date>
    </item>
  </channel>
</rss>

