Dashboards & Visualizations

Dashboard panels: how do I avoid "typechecking failed" error?

Motivator

Hi,

I'm getting the error "Error in eval command" typechecking failed * only takes numbers" on one of my dashboard panels. It eventually resolves itself as the panel that has the problem depends on two other panels. Once the other panels finishes, the error goes away and displays the correct value. What I'm hoping to do is to either hide the panel until complete (less desirable) or have the panel read 0 or blank until the other panels finish (more desirable). I've tried initializing the token values (tokcvr/toknoncvr) to zero at the start of the dashboard along with the eval variable (percentage) (at the top and in the query itself) but no luck. Any thoughts?

Here is a screenshot of the error
alt text

Here is the XML Code

<row>
    <panel>
      <title>Number of non-CVR sessions from $displayTime$ to $time_field.latest$</title>
      <single>
        <search>
          <done>
            <condition>
              <set token="toknoncvr">0</set>
            </condition>
            <condition match="$job.resultCount$==0">
              <set token="toknoncvr">0</set>
            </condition>
            <condition>
              <set token="toknoncvr">$result.noncvr$</set>
            </condition>
          </done>
          <query>index=wholesale_app buildTarget="blah"  NOT (analyticType=CustomAnalytic Properties.index>=17 AND Properties.index<=32)|rename Properties.index as pindex|dedup clientSessionId |stats count as noncvr</query>
          <earliest>$time_field.earliest$</earliest>
          <latest>$time_field.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </single>
    </panel>
    <panel>
      <title>Number of CVR sessions from $displayTime$ to $time_field.latest$</title>
      <single>
        <search>
          <done>
            <condition>
              <set token="tokcvr">0</set>
            </condition>
            <condition match="$job.resultCount$==0">
              <set token="tokcvr">0</set>
            </condition>
            <condition>
              <set token="tokcvr">$result.cvr$</set>
            </condition>
          </done>
          <query>index=wholesale_app buildTarget="blah" (analyticType=CustomAnalytic Properties.index>=17 AND Properties.index<=32)|rename Properties.index as pindex|dedup clientSessionId |stats count as cvr</query>
          <earliest>$time_field.earliest$</earliest>
          <latest>$time_field.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </single>
    </panel>
    <panel>
      <title>CVR Engagement Percentage</title>
      <single>
        <search>
          <query>|makeresults|eval percentage=0|eval percentage=round($tokcvr$/$toknoncvr$*100,2)|table percentage</query>
        </search>
        <option name="numberPrecision">0.00</option>
        <option name="unit">%</option>
      </single>
    </panel>
  </row>
  <row>

Legend

@dbcase, try the following in the eval section:

| eval percentage=round((($tokcvr$/$toknoncvr$)*100),2)

Following is a run anywhere example based on the details provided.

<dashboard>
  <label>Tokens in eval</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
          | fields - _time
          | eval noncvr=10
          </query>
          <done>
            <condition match="$job.resultCount$==0">
              <set token="toknoncvr">0</set>
            </condition>
            <condition>
              <set token="toknoncvr">$result.noncvr$</set>
            </condition>
          </done>
        </search>
      </table>
    </panel>
    <panel>
      <table>
        <search>
          <query>| makeresults
          | fields - _time
          | eval cvr=5
          </query>
          <done>
            <condition match="$job.resultCount$==0">
              <set token="tokcvr">0</set>
            </condition>
            <condition>
              <set token="tokcvr">$result.cvr$</set>
            </condition>
          </done>
        </search>
      </table>
    </panel>
  </row>
  <row>
    <panel>
       <single>
         <search>
           <query>| makeresults
| fields - _time
| eval percentage=0
| eval percentage=round((($tokcvr$/$toknoncvr$)*100),2)
| table percentage</query>
         </search>
         <option name="numberPrecision">0.00</option>
         <option name="unit">%</option>
       </single>      
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Motivator

Hmmm, tried this answer and the one above. I'm still getting the type checking failed.

I think it is because the tokcvr and toknoncvr are not set yet and this panel is trying to evaluate them.

Any other thoughts?

0 Karma

Legend

@dbcase if the token is not set you should see Waiting for input. Moreover using job.resultCount, you are defaulting the token to 0.

My Sample is a run anywhere dashboard. Does that also does not run for you? What is the Splunk version you are on?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Motivator

Hi Niketnilay,

Your dashboard works great. The difference is the time it takes on my dashboard to compute toknoncvr (30-45seconds). During that time the type checking error is displayed on the panel. Once the query that sets toknoncvr is complete the type checking error goes away and the correct value is set.

On your comment that the default is 0, I wonder if both tokens are set to 0 so there is a 0/0 computation that Splunk doesn't know what to do with.

0 Karma

Motivator

I just changed the defaulting the token to 0 to defaulting the token to 1 as a test and the type checking error went away, however, the number that was displayed while waiting on the query to finish was laughably wrong :). So it is a 0/0 problem that is causing Splunk to have fits. I'm thinking now to hide the panel until the long running query finishes, unless you have a "magic button" idea 🙂

0 Karma

Legend

@dbcase, Splunk does provide you that through depends attribute to your visualization element i.e. could be row, panel, input, visualizations like table, chart, html etc. Only when token/s in depends are set the respective visualization will be displayed.

In the <panel> where toknoncvr and tokcvr are used... add depends token to display them only when they are set....

   <row depends="$tokcvr$,$toknoncvr$">
     <panel>
        <single>
          <search>
            <query>| makeresults
 | fields - _time
 | eval percentage=0
 | eval percentage=round((($tokcvr$/$toknoncvr$)*100),2)
 | table percentage</query>
          </search>
          <option name="numberPrecision">0.00</option>
          <option name="unit">%</option>
        </single>      
     </panel>
   </row>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Motivator

Hey@dbcase,

It shows the error to be in eval.Can you try this:
eval percentage=round(('$tokcvr$'/'$toknoncvr$')*100,2).
Let me know if this helps!!

Motivator

Hmmm, tried this answer and the one below. I'm still getting the type checking failed.

I think it is because the tokcvr and toknoncvr are not set yet and this panel is trying to evaluate them.

Any other thoughts?

0 Karma

Legend

@deepashri_123 slight correction single quote based escape is not required. I think both tokens have numeric values. Issue is due to brackets not in correct place in the original question.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!