Dashboards & Visualizations

Nested Token Usage

bharathkumarnec
Contributor

Hi All,

I wanted to pass a token value into another input drop down:

If Token1=4 & Token2=S Query1 should run
If Token1=5 & Token2=S Query2 should run
If Token1=4 & Token2=N Query2 should run
If Token1=5 & Token2=N Query2 should run

Kindly help me out in this scenario.

Regards,
BK

0 Karma
1 Solution

mdsnmss
SplunkTrust
SplunkTrust

There is a way to have conditional components on dashboards using the "depends" input attribute. A good start would be to look at the "depends" options on this page: http://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML.

When you define the tokens you can set/unset additional tokens based on your input values. it might look something like this:

<input (your input settings)>
     <change>
          <condition match=($token1$==4 AND $token2$==S)>
              <set token="query1"></set>
              <unset token="query2"></unset>
          </condition>
          <condition match=($token1$!=4 AND $token2$!=S)>
              <set token="query2"></set>
              <unset token="query1"></unset>
          </condition>
     </change>
</input>

You would then use depends for the two searches to either hide or display them. This would be something like:

<panel depends="$query1$">
        <title>Query 1</title>
             <search><query>Your Query1</query></search>
</panel>
<panel depends="$query2$">
        <title>Query 2</title>
             <search><query>Your Query2</query></search>
</panel>

There may be some slight adjustments in the syntax needed and your panels will need viz options. Hopefully this gets you set on the right direction. Depending on how you set your tokens (might not be an input) there will be some adjustments needed.

View solution in original post

0 Karma

mdsnmss
SplunkTrust
SplunkTrust

There is a way to have conditional components on dashboards using the "depends" input attribute. A good start would be to look at the "depends" options on this page: http://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML.

When you define the tokens you can set/unset additional tokens based on your input values. it might look something like this:

<input (your input settings)>
     <change>
          <condition match=($token1$==4 AND $token2$==S)>
              <set token="query1"></set>
              <unset token="query2"></unset>
          </condition>
          <condition match=($token1$!=4 AND $token2$!=S)>
              <set token="query2"></set>
              <unset token="query1"></unset>
          </condition>
     </change>
</input>

You would then use depends for the two searches to either hide or display them. This would be something like:

<panel depends="$query1$">
        <title>Query 1</title>
             <search><query>Your Query1</query></search>
</panel>
<panel depends="$query2$">
        <title>Query 2</title>
             <search><query>Your Query2</query></search>
</panel>

There may be some slight adjustments in the syntax needed and your panels will need viz options. Hopefully this gets you set on the right direction. Depending on how you set your tokens (might not be an input) there will be some adjustments needed.

0 Karma

bharathkumarnec
Contributor

Thanks for the inputs!

The above mentioned change conditions need to be incorporated under dropdown inputs where we assigned tokens?? or oustide the dropdown inputs??

0 Karma

bharathkumarnec
Contributor

and also if i am giving like below, it is throwing me a warning saying invalid attribute name:

<condition match=($token1$==4 AND $token2$==S)>
0 Karma

bharathkumarnec
Contributor

@mdsnmss it worked after making some tweeking. Thanks for the help!

0 Karma

mdsnmss
SplunkTrust
SplunkTrust

Sorry, just saw the previous comments. Glad you were able to get it working!

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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