<?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: where with empty subsearch result raises an error message in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708276#M239529</link>
    <description>&lt;P&gt;Use the &lt;FONT face="courier new,courier"&gt;appendpipe&lt;/FONT&gt; command to add synthetic results when the subsearch finds nothing.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where [
      | loadjob $stoermeldungen_sid$
      | where stoerCode IN ("S00")
      | addinfo
      | where importZeit_unixF &amp;amp;gt;= relative_time(info_max_time,"-d@d") AND importZeit_unixF &amp;amp;lt;= relative_time(info_max_time,"@d")
      | stats count as dayCount by zbpIdentifier
      | sort -dayCount 
      | head 10
      | appendpipe [|stats count as Count | eval zbpIdentifier="Nothing found" | where Count=0 | fields - Count]
      | table zbpIdentifier ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2025 17:26:07 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2025-01-08T17:26:07Z</dc:date>
    <item>
      <title>where with empty subsearch result raises an error message</title>
      <link>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708275#M239528</link>
      <description>&lt;P&gt;Dear experts&lt;/P&gt;&lt;P&gt;Based on the following search:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  &amp;lt;search id="subsearch_results"&amp;gt;
    &amp;lt;query&amp;gt;
      search index="iii" search_name="nnn" Umgebung="uuu" 
        isbName="isb"
        status IN ("ALREADY*", "NO_NOTIF*", "UNCONF*", "NOTIF*")
        zbpIdentifier NOT 453-8888
        stoerCodeGruppe NOT ("GUT*")
        | eval  importZeit_unixF = strptime(importZeit, "%Y-%m-%dT%H:%M:%S.%N%Z")
        | eval importZeit_humanF = strftime(importZeit_unixF, "%Y-%m-%d %H:%M:%S")
        | table importZeit_humanF importZeit_unixF zbpIdentifier status stoerCode stoerCodeGruppe
      &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;$t_time.earliest$&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;$t_time.latest$@d&amp;lt;/latest&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;condition&amp;gt;
        &amp;lt;set token="stoermeldungen_sid"&amp;gt;$job.sid$&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;I try to load some data with:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;query&amp;gt;
   | loadjob $stoermeldungen_sid$
   | where stoerCode IN ("S00")
   | where [
      | loadjob $stoermeldungen_sid$
      | where stoerCode IN ("S00")
      | addinfo
      | where importZeit_unixF &amp;amp;gt;= relative_time(info_max_time,"-d@d") AND importZeit_unixF &amp;amp;lt;= relative_time(info_max_time,"@d")
      | stats count as dayCount by zbpIdentifier
      | sort -dayCount 
      | head 10
      | table zbpIdentifier ]
   | addinfo
   | where ....&lt;/LI-CODE&gt;&lt;P&gt;Basic idea:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;the subsearch first derives the top 10 of the elements based on the number of yesterdays error messages.&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;based on the subsearch result then the 7 day history is read and displayed (not fully shown in the example above)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;All works fine except if there are no messages found by the subsearch. If yesterday no error messages of the given type were recorded, the subsearch returns a result which causes the following error message in the dashboard:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in ´where´command: The expression is malformed. An unexpected character is reached at ´)´.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The where command is the one which should take the result of the subsearch (3rd line of code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error message is just not nice for the end user, better would be to get just an empty chart if no data is found.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is: How to fix the result of the subsearch in a way, that also the main search runs and gets the proper empty result, and therefore the empty graph instead of the "not nice" error message?&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 17:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708275#M239528</guid>
      <dc:creator>Ste</dc:creator>
      <dc:date>2025-01-08T17:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: where with empty subsearch result raises an error message</title>
      <link>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708276#M239529</link>
      <description>&lt;P&gt;Use the &lt;FONT face="courier new,courier"&gt;appendpipe&lt;/FONT&gt; command to add synthetic results when the subsearch finds nothing.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where [
      | loadjob $stoermeldungen_sid$
      | where stoerCode IN ("S00")
      | addinfo
      | where importZeit_unixF &amp;amp;gt;= relative_time(info_max_time,"-d@d") AND importZeit_unixF &amp;amp;lt;= relative_time(info_max_time,"@d")
      | stats count as dayCount by zbpIdentifier
      | sort -dayCount 
      | head 10
      | appendpipe [|stats count as Count | eval zbpIdentifier="Nothing found" | where Count=0 | fields - Count]
      | table zbpIdentifier ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 17:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708276#M239529</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-01-08T17:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: where with empty subsearch result raises an error message</title>
      <link>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708316#M239542</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;The perfect solution, exactly what I was looking for.&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 05:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/where-with-empty-subsearch-result-raises-an-error-message/m-p/708316#M239542</guid>
      <dc:creator>Ste</dc:creator>
      <dc:date>2025-01-09T05:25:12Z</dc:date>
    </item>
  </channel>
</rss>

