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!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...