Dashboards & Visualizations

Parse the pan+zoom selection $start$ and $end$ tokens in non-timechart charts

arkadyz1
Builder

We've used <selection> tag quite successfully for our timecharts. The regular

<selection>
  <set token="slider.start">$start$</set>
  <set token="slider.end">$end$</set>
</selection>

addition to a timechart populates the slider.start and slider.end tokens quite fine each time a user makes a selection or pans it. They get the starting and ending epoch times, respectively.

However, the same approach fails miserably for non-time charts. If, say, a span of some column is 965 to 970 of independent variable, and that column happens to become the first one in the selection, we'll get "965-970" inside the $slider.start$ token.

How can we set the token properly - extracting that 965 from it? This panel is going to be exported to HTML at some point, but is there an easier way for now? We still have a lot of development ahead of us.

Tags (4)
0 Karma
1 Solution

arkadyz1
Builder

Well - we finally got some time to look closer into it, and found some way which is not documented for the <selection> tag but is used elsewhere: <eval> tag.

The code looks like this:

<selection>
          <eval token="histogram.start">mvindex(split('start',"-"),0)</eval>
          <eval token="histogram.end">mvindex(split('end',"-"),1)</eval>
</selection>

This code sets the $histogram.start$ token to the lower boundary of the first column inside the selection and $histogram.end$ to the upper one. Also works if there is no selection - defaults to the whole range.

I only wish it were documented better...

View solution in original post

0 Karma

puladamscom
Explorer

Alternatively, a neat little trick to avoid the <eval> thing is to avoid the dashes in the x-axis values in the first place. To do that, just change span=5 to span=5s. I know it seems strange but believe me it works - just do it and you will see!

0 Karma

arkadyz1
Builder

Well - we finally got some time to look closer into it, and found some way which is not documented for the <selection> tag but is used elsewhere: <eval> tag.

The code looks like this:

<selection>
          <eval token="histogram.start">mvindex(split('start',"-"),0)</eval>
          <eval token="histogram.end">mvindex(split('end',"-"),1)</eval>
</selection>

This code sets the $histogram.start$ token to the lower boundary of the first column inside the selection and $histogram.end$ to the upper one. Also works if there is no selection - defaults to the whole range.

I only wish it were documented better...

0 Karma
Get Updates on the Splunk Community!

March Community Office Hours Security Series Uncovered!

Hello Splunk Community! In March, Splunk Community Office Hours spotlighted our fabulous Splunk Threat ...

Stay Connected: Your Guide to April Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars in April. This post ...

Want to Reduce Costs, Mitigate Risk, Improve Performance, or Increase Efficiencies? ...

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