Dashboards & Visualizations

Check Multiple conditions for different dropdown values

ankursaxena2020
Engager

I want to set a token value based on different dropdown values. eg:

<input type="dropdown" token="endpoint" searchWhenChanged="true">

    <label>endpoint</label>

    <choice value=“/abc”>/abc</choice>

    <choice value=“/defb”>/def</choice>

    <choice value=“/xyz”>/xyz</choice>

    <default>/abc</default>

    <initialValue>/abc</initialValue>

</input>

 

<input type="dropdown" token="environment" searchWhenChanged="true">

    <label>environment</label>

    <choice value="prod">prod</choice>

    <choice value="ppe">pre-prod</choice>

    <choice value="dev">dev</choice>

    <default>prod</default>

    <initialValue>prod</initialValue>

</input>

 

In this example,

1. I want to set a token(named as targetName) value to "employee" if the endpoint value is /def and environment is prod. 

2. TargetName should be set to "address" for any other endpoint with environment value as prod.

 

 

Labels (3)
0 Karma
1 Solution

niketn
Legend

@ankursaxena2020 you have given two conditions for Prod, what if environment is not Prod, how do you want to handle those conditions?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@ankursaxena2020 you have given two conditions for Prod, what if environment is not Prod, how do you want to handle those conditions?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketn
Legend

@ankursaxena2020 seems like you accepted my question as answer by mistake. If your query is already resolved it is possibly based on Rich's answer. So accept his answer if no further queries!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try using condition.

<input type="dropdown" token="endpoint" searchWhenChanged="true">
    <label>endpoint</label>
    <choice value=“/abc”>/abc</choice>
    <choice value=“/defb”>/def</choice>
    <choice value=“/xyz”>/xyz</choice>
    <default>/abc</default>
    <initialValue>/abc</initialValue>
    <condition match="match($endpoint$,&quot;/def&quot;) AND match($environment$, &quot;prod&quot;)">
      <set token="targetName">employee</set>
    </condition>
    <condition match="NOT match($endpoint$,&quot;/def&quot;) AND match($environment$, &quot;prod&quot;)">
      <set token="targetName">address</set>
    </condition>
</input>

<input type="dropdown" token="environment" searchWhenChanged="true">
    <label>environment</label>
    <choice value="prod">prod</choice>
    <choice value="ppe">pre-prod</choice>
    <choice value="dev">dev</choice>
    <default>prod</default>
    <initialValue>prod</initialValue>
    <condition match="match($endpoint$,&quot;/def&quot;) AND match($environment$, &quot;prod&quot;)">
      <set token="targetName">employee</set>
    </condition>
    <condition match="NOT match($endpoint$,&quot;/def&quot;) AND match($environment$, &quot;prod&quot;)">
      <set token="targetName">address</set>
    </condition>
</input>

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...