Dashboards & Visualizations

Multiselect input filter using case statement

gemrose
Explorer

Hello Team,

I am trying for a solution using multiselect input filter where the index token is passed to panels.

From the below code, I currently see the filter values "Stack1", "Stack2" and "Stack3". But I face an issue that the value passed is from label. I need the index_tkn to hold value aws_stack02_p, aws_stack01_p, aws_stack01`_n.

<input type="multiselect" token="index_tkn" searchWhenChanged="false">
<label>Select Stack</label>
<valuePrefix>index="</valuePrefix>
<valueSuffix>"</valueSuffix>
<delimiter> OR </delimiter>
<fieldForLabel>index</fieldForLabel>
<fieldForValue>label</fieldForValue>
<search>
<query>index IN ({aws_stack02_p,aws_stack01_p,aws_stack01_n})
| eval label = case(index == "aws_stack02_p", "Stack1",index == "aws_stack01_p", "Stack2",index == "aws_stack01_n", "Stack3")
|stats count by label</query>
<earliest>$time_tkn.earliest$</earliest>
<latest>$time_tkn.latest$</latest>
</search>
</input>

 

Labels (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Since you appear to have a one-to-one relationship between label and index, just include both in the by clause

<query>index IN ({aws_stack02_p,aws_stack01_p,aws_stack01_n})
| eval label = case(index == "aws_stack02_p", "Stack1",index == "aws_stack01_p", "Stack2",index == "aws_stack01_n", "Stack3")
|stats count by label,index</query>
0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...