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 (2)
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

 

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Get Agentic with Splunk Lantern: Connect to Cisco Cloud Control, Transform ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

July Community Events: Master ITSI 5.0 & Automate Splunk

Struggling with alert fatigue or feeling like you're spending more time on infrastructure maintenance than ...

New Release of Federated Search: Bringing Splunk Analytics to More of Your Data

Organizations today are generating more data than ever and storing it across cloud object stores, data lakes, ...