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!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...