Hi,
I have the XML code. What is happening with the mso_selection token after the dashboard is loaded is:
If you select item number 2 in the Select a MSO dropdown the Subscriber count panel & query work
if you then select item number 1 in the Select MSO dropdown the Subscriber count panel & query work
if you then select item number 2 again the mso_selection token is still set to item number 1 and it uses the wrong query
I can't figure out why the mso_selection token isn't updating correctly, any thoughts?
<form>
<label>Wholesale App Dashboard Clone</label>
<fieldset autoRun="true" submitButton="false">
<input type="time" token="time_field">
<label>Please select a time period</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="mso_selection" searchWhenChanged="true">
<label>Select a MSO</label>
<search>
<query>index=wholesale_app sourcetype=wholesale_mobile_app buildTarget | dedup buildTarget</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>buildTarget</fieldForLabel>
<fieldForValue>buildTarget</fieldForValue>
<choice value="*">All</choice>
<default>*</default>
<initialValue>*</initialValue>
<change>
<condition value="All">
<set token="subscriberCount_all">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|stats sum(Subscribers) as count</set>
<unset token="subscriberCount_mso"></unset>
</condition>
<condition>
<set token="subscriberCount_mso">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$mso_selection$%") |stats sum(Subscribers) as count</set>
<unset token="subscriberCount_all"></unset>
</condition>
</change>
</input>
<input type="dropdown" token="Product_token" searchWhenChanged="true">
<label>Select a Product</label>
<search>
<query>index=wholesale_app product|dedup product</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>product</fieldForLabel>
<fieldForValue>product</fieldForValue>
<choice value="*">- All -</choice>
<default>*</default>
<initialValue>*</initialValue>
</input>
</fieldset>
<row>
<panel>
<title>Subscriber Count</title>
<single depends="$subscriberCount_all$">
<title>Subscriber Count All</title>
<search>
<query>$subscriberCount_all$</query>
</search>
</single>
<single depends="$subscriberCount_mso$">
<title>Subscriber Count - $mso_selection$</title>
<search>
<query>$subscriberCount_mso$</query>
</search>
</single>
</panel>
</row>
</form>
[UPDATED]
Just noticed the Token subscriberCount
being set inside the dropdown mso_selection
. You should use default dropdown tokens i.e. $value$ and $label$ respectively for using the value or label of the dropdown within the change event. If you use the dropdown form token variable within the same dropdown's change event then obviously the value will be available only after posting i.e. delay of one click or change.
Use the $value$
instead of $mso_selection$
in the query below.
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$value$%") |stats sum(Subscribers) as count</set>
@dbcase, this seems to be a duplicate of question https://answers.splunk.com/answers/596962/token-in-a-drop-down-not-being-set-properly.html
Try setting a default
value for dropdown mso_selection
and remove the code to unset
token. Also you don't need two separate tokens and two separate Single Value only one can be set and needs to be displayed.
Try the following Simple XML code:
<form>
<label>Wholesale App Dashboard Clone</label>
<fieldset autoRun="true" submitButton="false">
<input type="time" token="time_field">
<label>Please select a time period</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="mso_selection" searchWhenChanged="true">
<label>Select a MSO</label>
<search>
<query>index=wholesale_app sourcetype=wholesale_mobile_app buildTarget | dedup buildTarget</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>buildTarget</fieldForLabel>
<fieldForValue>buildTarget</fieldForValue>
<choice value="*">All</choice>
<change>
<condition label="All">
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|stats sum(Subscribers) as count</set>
<set token="mso_selection_label">$label$</set>
</condition>
<condition>
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$value$%") |stats sum(Subscribers) as count</set>
<set token="mso_selection_label">$label$</set>
</condition>
</change>
</input>
<input type="dropdown" token="Product_token" searchWhenChanged="true">
<label>Select a Product</label>
<search>
<query>index=wholesale_app product|dedup product</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>product</fieldForLabel>
<fieldForValue>product</fieldForValue>
<choice value="*">- All -</choice>
<default>*</default>
<initialValue>*</initialValue>
</input>
</fieldset>
<row>
<panel>
<title>Subscriber Count</title>
<single depends="$subscriberCount$">
<title>Subscriber Count $mso_selection_label$</title>
<search>
<query>$subscriberCount$</query>
</search>
</single>
</panel>
</row>
</form>
[UPDATED]
Just noticed the Token subscriberCount
being set inside the dropdown mso_selection
. You should use default dropdown tokens i.e. $value$ and $label$ respectively for using the value or label of the dropdown within the change event. If you use the dropdown form token variable within the same dropdown's change event then obviously the value will be available only after posting i.e. delay of one click or change.
Use the $value$
instead of $mso_selection$
in the query below.
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$value$%") |stats sum(Subscribers) as count</set>
@dbcase, this seems to be a duplicate of question https://answers.splunk.com/answers/596962/token-in-a-drop-down-not-being-set-properly.html
Try setting a default
value for dropdown mso_selection
and remove the code to unset
token. Also you don't need two separate tokens and two separate Single Value only one can be set and needs to be displayed.
Try the following Simple XML code:
<form>
<label>Wholesale App Dashboard Clone</label>
<fieldset autoRun="true" submitButton="false">
<input type="time" token="time_field">
<label>Please select a time period</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="mso_selection" searchWhenChanged="true">
<label>Select a MSO</label>
<search>
<query>index=wholesale_app sourcetype=wholesale_mobile_app buildTarget | dedup buildTarget</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>buildTarget</fieldForLabel>
<fieldForValue>buildTarget</fieldForValue>
<choice value="*">All</choice>
<change>
<condition label="All">
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|stats sum(Subscribers) as count</set>
<set token="mso_selection_label">$label$</set>
</condition>
<condition>
<set token="subscriberCount">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$value$%") |stats sum(Subscribers) as count</set>
<set token="mso_selection_label">$label$</set>
</condition>
</change>
</input>
<input type="dropdown" token="Product_token" searchWhenChanged="true">
<label>Select a Product</label>
<search>
<query>index=wholesale_app product|dedup product</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>product</fieldForLabel>
<fieldForValue>product</fieldForValue>
<choice value="*">- All -</choice>
<default>*</default>
<initialValue>*</initialValue>
</input>
</fieldset>
<row>
<panel>
<title>Subscriber Count</title>
<single depends="$subscriberCount$">
<title>Subscriber Count $mso_selection_label$</title>
<search>
<query>$subscriberCount$</query>
</search>
</single>
</panel>
</row>
</form>
Hi Nietnilay!
BINGO!!!! that did the trick! Many many thanks!!!
Anytime... Happy Friday 🙂
Hi Niketnilay,
Thanks for the prompt reply! I was soooo hopeful, but the behavior is still there. After you select the first two items (and it works) from the 3rd selection on, the token is lagging one selection behind
I.e.
Select item 1 (good)
select item 2 (good)
select item 3 (bad - token is set to item2)
select item 4 (bad - token is set to item3)
etc etc
Oh and just FYI - I used your xml code as is, no modifications
one other piece of info, the single panel label changes just fine, is just the query that trails behind
@dbcase, I have updated my answer. You are using $mso_selection$ with mso_selection
dropdown's change event. Hence the value is available after posting change i.e. delay of one click. Use $value$
inside the <change>
event to set the subscriberCount
token for else condition. As you have already noticed, this is the reason why $label$
is showing correct label on <change>
event.
Please try out and confirm.
fixed some errors but the behavior is still the same. Here is the updated dashboard
<form>
<label>Wholesale App Dashboard Clone</label>
<fieldset autoRun="true" submitButton="false">
<input type="time" token="time_field">
<label>Please select a time period</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="mso_selection" searchWhenChanged="true">
<label>Select a MSO</label>
<search>
<query>index=wholesale_app sourcetype=wholesale_mobile_app buildTarget | dedup buildTarget</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>buildTarget</fieldForLabel>
<fieldForValue>buildTarget</fieldForValue>
<choice value="*">All</choice>
<change>
<condition label="All">
<unset token="subscriberCount_mso"></unset>
<unset token="mso_selection"></unset>
<set token="subscriberCount_all">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|stats sum(Subscribers) as count</set>
</condition>
<condition>
<unset token="subscriberCount_all"></unset>
<set token="subscriberCount_mso">index=mso_statistics sourcetype=ic_connectivity_5min-too_small stat_name=subscribers |rex "\d+\s(?<mso>\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%$mso_selection$%") |stats sum(Subscribers) as count</set>
</condition>
</change>
</input>
<input type="dropdown" token="Product_token" searchWhenChanged="true">
<label>Select a Product</label>
<search>
<query>index=wholesale_app product|dedup product</query>
<earliest>-1d</earliest>
<latest>now</latest>
</search>
<fieldForLabel>product</fieldForLabel>
<fieldForValue>product</fieldForValue>
<choice value="*">- All -</choice>
<default>*</default>
<initialValue>*</initialValue>
</input>
</fieldset>
<row>
<panel>
<title>Subscriber Count</title>
<single depends="$subscriberCount_all$">
<title>Subscriber Count All</title>
<search>
<query>$subscriberCount_all$</query>
</search>
</single>
<single depends="$subscriberCount_mso$">
<title>Subscriber Count - $mso_selection$</title>
<search>
<query>$subscriberCount_mso$</query>
</search>
</single>
</panel>
</row>
</form>