Dashboards & Visualizations

Why doesn't drilldown eval token statement work unless broken into two steps?

bowesmana
SplunkTrust
SplunkTrust

Can anyone explain why the k1 eval token statement does not work, but k2 and k3, which do the same as k1, but in two steps, does.

 

<eval token="k1">mvindex($row.key$, mvfind($row.name$, $click.value2$))</eval>
<eval token="k2">mvfind($row.name$, $click.value2$)</eval>
<eval token="k3">mvindex($row.key$, $k2$)</eval>

 

Requirements are: 2 MV fields in a single row with keys in one field and names in the other. drilldown is cell and click.value2 is the clicked name (key column is hidden).

I'm trying to grab the corresponding key for the clicked name. I finally got k2/k3 combination working, but am puzzled why k1 does not work and don't know how to diagnose.

Here's an example dashboard.

 

<dashboard>
  <label>MV Click</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
| fields - _time
| eval name=split("ABCDEFGHIJKL", "")
| eval key=lower(name)
| table name key</query>
          <earliest>@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <fields>name</fields>
        <option name="count">100</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <drilldown>
          <eval token="k1">mvindex($row.key$, mvfind($row.name$, $click.value2$))</eval>
          <eval token="k2">mvfind($row.name$, $click.value2$)</eval>
          <eval token="k3">mvindex($row.key$, $k2$)</eval>
          <set token="name">$click.value2$</set>
          <set token="names">$row.name$</set>
          <set token="keys">$row.key$</set>
        </drilldown>
      </table>
    </panel>
    <panel>
      <html>
        <h2>Clicked name=$name$</h2><p/>
        <h2>Names=$names$</h2>
        <h2>Keys=$keys$</h2><p/>
        <h3>&lt;eval token="k1">mvindex($row.key$, mvfind($row.name$, $click.value2$))&lt;/eval> = $k1$</h3>
        <h3>&lt;eval token="k2">mvfind($row.name$, $click.value2$)&lt;/eval> = $k2$</h3>
        <h3>&lt;eval token="k3">mvindex($row.key$, $$k2$$)&lt;/eval> = $k3$</h3>
      </html>
    </panel>
  </row>
</dashboard>

 

Labels (3)
Tags (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I thought it might be eval not being able to process more than one $row.xxx$ field but it isn't that - I updated your example to use mvzip to prove it - looks like a bug to me 😀

<dashboard>
  <label>MV Click</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
| fields - _time
| eval name=split("ABCDEFGHIJKL", "")
| eval key=lower(name)
| table name key</query>
          <earliest>@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <fields>name</fields>
        <option name="count">100</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <drilldown>
          <eval token="k1">mvindex($row.key$, int(mvfind($row.name$, $click.value2$)))</eval>
          <eval token="k2">mvfind($row.name$, $click.value2$)</eval>
          <eval token="k3">mvindex($row.key$, $k2$)</eval>
          <eval token="k4">mvzip($row.key$,$row.name$,"|")</eval>
          <set token="name">$click.value2$</set>
          <set token="names">$row.name$</set>
          <set token="keys">$row.key$</set>
        </drilldown>
      </table>
    </panel>
    <panel>
      <html>
        <h2>Clicked name=$name$</h2><p/>
        <h2>Names=$names$</h2>
        <h2>Keys=$keys$</h2><p/>
        <h3>&lt;eval token="k1">mvindex($row.key$, mvfind($row.name$, $click.value2$))&lt;/eval> = $k1$</h3>
        <h3>&lt;eval token="k2">mvfind($row.name$, $click.value2$)&lt;/eval> = $k2$</h3>
        <h3>&lt;eval token="k3">mvindex($row.key$, $$k2$$)&lt;/eval> = $k3$</h3>
        <h3>&lt;eval token="k4">mvzip($row.key$,$row.name$,"|")&lt;/eval> = $k4$</h3>
      </html>
    </panel>
  </row>
</dashboard>
0 Karma

bowesmana
SplunkTrust
SplunkTrust

@ITWhisperer I posted also on Slack and @jeffland did a great job of working out what the issue is. 

In the JS that evaluates the mvfind() in the k1 case, it returns a data type of mv, which then silently throws an error when it's passed to mvindex(). The solution in that case is to force it into a number by wrapping it in 

eval token="k1">mvindex($row.key$, tonumber(tostring(mvfind($row.name$, $click.value2$)))))</eval>

so yes it does appear to be a bug - I have occasionally found eval token setters not to work and never understood why. I tagged you in the slack channel dashboards_simple_xml

 

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...