Handlebars syntax in TSVB Markdown panel with conditional output for multiple items?


I have two dashboards:

  • Dashboard A is designed to present information about multiple items.
  • Dashboard B is designed to present information about one of those items.

Visualizations in dashboard A drill-down to dashboard B: when the user clicks an item in dashboard A, the user is presented with an option to go to dashboard B, filtered by that item.

While dashboard B is intended to show information about a single item, users could also choose to bypass the drill-down from dashboard A, and go directly to dashboard B.

More specifically, the items on these dashboards are "jobs", identified by a job_name field.

In dashboard B, I want to show job_name as a heading, because I don't feel that the filter is prominent enough.

I have a TSVB Markdown panel with the following details:

Aggregration: Count
Group by: Terms
By: job_name

The resulting objects accessible via Handlebars expressions have a job_name value as their first qualifier. For example, given a job_name value of MASTER, then the following Handlebars syntax:

{{ master.label }}

results in the Markdown panel displaying the string:


More usefully, if the dashboard is filtered to show only a single job_name, then the following combination of Markdown and Handlebars syntax:

## Job name: {{#each _all}}{{label}} {{/each}}

results in the heading:

Job name: MASTER

However, if the dashboard isn't filtered to show a single job_name, then "Job name: " is followed by numerous job names. I don't want that.


In a TSVB Markdown panel, can I use Handlebars syntax to test for the presence of multiple values of job_name, and then, if multiple values are found, display a message recommending that the user creates a filter; otherwise, as now, display the single job name in a heading?

Even after reading the Handlebars documentation, I don't know how to do this, or even if it's possible.

My fuzzy idea is to use the built-in helper #if to test the number of "children" (first-level keys) of _all. (I understand that _all is an object, not an array. There's no length property here.)

I know that I can use @index, like this (shows the index incrementing on each list item), but I'm not sure how this helps my use case:

{{#each _all}}
- {{label}} {{@index}}

Some detailed docs on what helpers are available in sub-expressions would be useful here.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.