Dashboards & Visualizations

How do I make a conditional title based on a token value in a dashboard panel?

orinciog
New Member

Hello!

I have a chart that shows data based on a variable $sourcetype_tok$. The values of the dropdown list are as follows:

  1. A list of categories from a query
  2. A static one that has the name all and the value * that should represent all the categories combined

However, the chart's title should depend on the selected category. Until now, I have this:

<title>
    Top 10: $sourcetype_tok$ domains
</title>

If the selected category is A, it works.

However, if I select the value all, the title will be Top 10: * domains and I want it to be customizable. Is there a way I can insert fields such as <title> conditionally? Or can I do something so the title would depend on the value of a token?

Thanks!

Labels (1)
0 Karma
1 Solution

jeffland
SplunkTrust
SplunkTrust

Simple. Add a change event to your input like this:

<input type="dropdown" token="sourcetype_tok">
  <...>
  <change>
    <condition value="*">
      <set token="display_domain_names">Unfiltered</set>
    </condition>
    <condition value="*">
      <set token="display_domain_names">$value$</set>
    </condition>
  </change>
</input>

This should make your input set a second token display_domain_names which contains the text "Unfiltered" if the user selects the "all" option or the selected value if another one is selected. Use this token in your title. If label and value are different in the dropdown and label is nicer, you also have $label$ available. Docs here.

View solution in original post

0 Karma

Vachel
Explorer

Hi, I would appreciated if any expert could show your experience:

I want my title shows 

ALL Status

when * Status is showed, now I have set a second token as 

<title>$displaykeystorestatus$ Status Overview</title>

if part of type is selected, then should show a certain type

<title>$form.type$ Status Overview</title>

 Now either of them can be achieved separately, but I cannot make the title into the conditional one,  could you help to share how to use the < change> and <condition> to combine these two scenarios? Many thanks.

0 Karma

Vachel
Explorer

Same question, just wonder how do you insert the <change>

Bec I also want to change the title based on the token condition, but <title> is not <input>, I do not find the correction to insert the <change> code

My goal is also to replace the * with ALL, thanks for support!

0 Karma

jeffland
SplunkTrust
SplunkTrust

Simple. Add a change event to your input like this:

<input type="dropdown" token="sourcetype_tok">
  <...>
  <change>
    <condition value="*">
      <set token="display_domain_names">Unfiltered</set>
    </condition>
    <condition value="*">
      <set token="display_domain_names">$value$</set>
    </condition>
  </change>
</input>

This should make your input set a second token display_domain_names which contains the text "Unfiltered" if the user selects the "all" option or the selected value if another one is selected. Use this token in your title. If label and value are different in the dropdown and label is nicer, you also have $label$ available. Docs here.

0 Karma

orinciog
New Member

Exactly what I needed!
Thanks!

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...