<?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: Timechart with no data gives &amp;quot;No results found&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318233#M95225</link>
    <description>&lt;P&gt;Slow clap. This is awesome @niketnilay&lt;/P&gt;</description>
    <pubDate>Sat, 02 Dec 2017 15:17:38 GMT</pubDate>
    <dc:creator>skoelpin</dc:creator>
    <dc:date>2017-12-02T15:17:38Z</dc:date>
    <item>
      <title>Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318229#M95221</link>
      <description>&lt;P&gt;I want to show the number of bad errors each minute over an hour time period to show as an embedded report.&lt;/P&gt;

&lt;P&gt;I am using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=foo "Bad error" | timechart span=1m count as "Bad Error"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am hitting the usual problem where if there were no bad errors in one hour the result is just "No results found" rather than a blank linechart.&lt;/P&gt;

&lt;P&gt;I've spent time looking at the fillnull suggestions etc but can't find anything that works for me. Ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 23:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318229#M95221</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-12-01T23:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318230#M95222</link>
      <description>&lt;P&gt;@burwell, get the &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;Splunk Dashboard Examples app&lt;/A&gt; from Splunkbase and check out &lt;CODE&gt;Null Result Swapper&lt;/CODE&gt; example. Basically Splunk gives your two attributes i.e. &lt;CODE&gt;depends&lt;/CODE&gt; and &lt;CODE&gt;rejects&lt;/CODE&gt;, which can be attached to any visualization element like row, panel or chart etc and depending on whether the required &lt;CODE&gt;token&lt;/CODE&gt; is &lt;CODE&gt;set&lt;/CODE&gt; or &lt;CODE&gt;unset&lt;/CODE&gt; they can &lt;CODE&gt;show&lt;/CODE&gt; or &lt;CODE&gt;hide&lt;/CODE&gt; the same.&lt;/P&gt;

&lt;P&gt;In your case you can use the &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt; or &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; search event handler to access one of default job token i.e. &lt;CODE&gt;$job.resultCount$&lt;/CODE&gt; which will be 0 in case of no results found.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;done&amp;gt;
    &amp;lt;condition match=" 'job.resultCount' == 0"&amp;gt;
        &amp;lt;set token="show_html"&amp;gt;true&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt;
    &amp;lt;condition&amp;gt;
        &amp;lt;unset token="show_html"/&amp;gt;
    &amp;lt;/condition&amp;gt;
&amp;lt;done&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to documentation: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/EventHandlerReference#done"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/EventHandlerReference#done&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Then use the token &lt;CODE&gt;$show_token$&lt;/CODE&gt; with &lt;CODE&gt;depends&lt;/CODE&gt; attribute to show timechart only when results exist. You can also add an HTML panel with &lt;CODE&gt;rejects&lt;/CODE&gt; attribute with the same token to show your custom error message in case no no results are found and &lt;CODE&gt;$show_tokens$&lt;/CODE&gt; is not set.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;chart rejects="$show_html$"&amp;gt;
   ...
&amp;lt;/chart&amp;gt;
&amp;lt;html depends="$show_token$"&amp;gt;
     &amp;lt;div style="font-weight:bold;font-size:150%;text-align:center;color:red"&amp;gt;
          No results found for selected timerange. Please relax the search filters or increase the time range.
     &amp;lt;/div&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try the following run anywhere dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Show hide using depends and rejects on no results found&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="time" token="tokTime" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Select Time&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;chart rejects="$show_html$"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level="ERROR"
          | timechart count&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$tokTime.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$tokTime.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;progress&amp;gt;
            &amp;lt;condition match="$job.resultCount$ == 0"&amp;gt;
              &amp;lt;set token="show_html"&amp;gt;true&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition&amp;gt;
              &amp;lt;unset token="show_html"/&amp;gt;
            &amp;lt;/condition&amp;gt;
          &amp;lt;/progress&amp;gt;         
        &amp;lt;/search&amp;gt;
      &amp;lt;/chart&amp;gt;
      &amp;lt;html depends="$show_html$"&amp;gt;
         &amp;lt;div style="font-weight:bold;font-size:150%;text-align:center;color:red"&amp;gt;
              No results found for selected timerange. Please relax the search filters or increase the time range.
         &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Dec 2017 03:13:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318230#M95222</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-02T03:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318231#M95223</link>
      <description>&lt;P&gt;Thanks for the detailed answer. Unfortunately, I need to embed the report in an iframe. As I understand it, I can't embed a dashboard.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 06:27:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318231#M95223</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-12-02T06:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318232#M95224</link>
      <description>&lt;P&gt;@burwell, there is a crooked way of embedding a dashboard to your webpage, but it opens up clickjacking attack. Refer to my answer: &lt;A href="https://answers.splunk.com/answers/582632/how-do-you-use-custom-xml-in-reports-from-dashboar.html#answer-584431"&gt;https://answers.splunk.com/answers/582632/how-do-you-use-custom-xml-in-reports-from-dashboar.html#answer-584431&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, if you want to stick to Report you can try a search like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd log_level=ERROR
| timechart count
| appendpipe 
    [| makeresults
    |  eval count=0]
    |  dedup _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It appends a dummy row for current time with count 0. If timechart with any record exist current _time will have either 0 or positive count. Hence dedup _time will reject appended dummy row.&lt;BR /&gt;
If timechart returns no results it will keep the dummy row for current time with count=0 hence it will show blank timechart instead of no results found. &lt;/P&gt;

&lt;P&gt;For you sample query you can try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=foo "Bad error" 
| timechart span=1m count as "Bad Error"
| appendpipe 
    [| makeresults
    |  eval "Bad Error"=0]
    |  dedup _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please see if one of these options works for you and confirm.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 11:24:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318232#M95224</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-02T11:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318233#M95225</link>
      <description>&lt;P&gt;Slow clap. This is awesome @niketnilay&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 15:17:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318233#M95225</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2017-12-02T15:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318234#M95226</link>
      <description>&lt;P&gt;@skoelpin, thanks it means a lot  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 16:00:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318234#M95226</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-02T16:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318235#M95227</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo "Bad Error"
| appendpipe [|makeresults]
| timechart span=1m count(searchmatch("Bad error")) AS "Bad Error"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Dec 2017 20:30:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318235#M95227</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-02T20:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318236#M95228</link>
      <description>&lt;P&gt;Hi Woodcock. So my "Bad Error" code was really status="500" and so I couldn't get this method to work. I wasn't sure what to put in the searchmatch..&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 02:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318236#M95228</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-12-03T02:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318237#M95229</link>
      <description>&lt;P&gt;Hi. Yes I did not want to open up clickjacking. Your solution above works perfectly! We see an empty timechart when there are no errors instead of the "No results" error. Perfect. Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 02:30:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318237#M95229</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-12-03T02:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318238#M95230</link>
      <description>&lt;P&gt;Yay! Glad one of the options worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 06:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318238#M95230</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-03T06:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318239#M95231</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo status="500"
| appendpipe [|makeresults]
| timechart span=1m count(eval(status="500")) AS "Bad Error"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It should be much simpler.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 16:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318239#M95231</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-03T16:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318240#M95232</link>
      <description>&lt;P&gt;Thanks Woodcock. This one does work and is about the same amount of time as the answer @niketnilay gave which I already accepted. I really appreciate the solution.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 01:35:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318240#M95232</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-12-04T01:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318241#M95233</link>
      <description>&lt;P&gt;This worked well for me. &lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 14:36:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318241#M95233</guid>
      <dc:creator>dbarnesroomstog</dc:creator>
      <dc:date>2018-03-15T14:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with no data gives "No results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318242#M95234</link>
      <description>&lt;P&gt;@dbarnesroomstogo, I am glad you found the answer useful. Do up vote the comment/s that helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 17:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-no-data-gives-quot-No-results-found-quot/m-p/318242#M95234</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-15T17:55:59Z</dc:date>
    </item>
  </channel>
</rss>

