i am trying to create a Splunk dashboard, where I want to set a value to a token based on the two dropdown values(service dropdown and environment dropdown)
<input type="dropdown" token="service" searchWhenChanged="true">
<label>service</label>
<choice value="capi">capi</choice>
<choice value="crapi">crapi</choice>
<choice value="oapi">oapi</choice>
<default>capi</default>
<initialValue>capi</initialValue>
</input>
<input type="dropdown" token="environment" searchWhenChanged="true">
<label>Environment</label>
<choice value="prod">prod</choice>
<choice value="ppe">ppe</choice>
<choice value="pte">pte</choice>
<choice value="dev">dev</choice>
<default>prod</default>
<initialValue>prod</initialValue>
</input>
above are the 2 dropdowns, now i want to set a value to token "endpoint" based on value selected in service and environment dropdown values.
i tried using condition match, but i am not getting it right
<condition match="$service$==capi AND $environment$==ppe">
<set token = endpoint>"/capi/ppe"</set>
</condition>
You need to put the right hand side of the test in escaped quotes and also all should be inside a <change> element, e.g.
<change>
<condition match="$service$="capi" AND $environment$="ppe"">
<set token="endpoint">/capi/ppe</set>
</condition>
</change>
and the quotes in the set need to be round the token name, not the value, unless you want the quotes in the value.
Hope this helps
Hi bowesmana,
firstly thanks for such a quick reply.
i tried to put the below code in my xml, but i still don't see $endpoint$ in search query being populated with the value set in condition.
probably i am using condition in wrong place.
below is my xml, please let me know where i am getting wrong.
<form>
<label>Apigee logs</label>
<description>Stats based on the logs of selected services </description>
<fieldset submitButton="false">
<input type="dropdown" token="service" searchWhenChanged="true">
<label>Service</label>
<choice value="capi">capi</choice>
<choice value="crapi">crapi</choice>
<default>capi</default>
<initialValue>capi</initialValue>
</input>
<input type="dropdown" token="environment" searchWhenChanged="true">
<label>Environment</label>
<choice value="ppe">ppe</choice>
<choice value="pte">pte</choice>
<default>ppe</default>
<initialValue>ppe</initialValue>
</input>
<change>
<condition match="$service$="capi" AND $environment$="ppe"">
<set token="endpoint">/capi/ppe</set>
</condition>
</change>
</input>
<row>
<panel>
<title>Response status codes over time</title>
<chart>
<title>only real traffic, excludes _status/_interface/(...) endpoints</title>
<search>
<query>index=api_$environment$
endpoint=$endpoint$
| timechart span="$time_span$" count by responseStatus</query>
</chart>
</panel>
</row>
</form>
Change elements are part of the <input> - you will need to have it in both inputs
Do you really want to always set the endpoint to /capi/ppe or do you want to set it to some part of the selected dropdowns.
If so, you should be using the dropdown tokens in the <set> statement for endpoint, e.g.
<set token="endpoint">/$service$/$environment$</set>
and in that case you would not need the condition either
Hi bowesmana, Thank you so much for replying back.
Below is my actual requirement
when $service$=capi AND $environment$=ppe
set $endpoint$ = /colleague/job
when $service=capi AND $environment$=dev
set $endpoint$=/merchant/profile
You just need to then add a <condition> and <set> pair for each condition you want inside those change blocks.