Dashboards & Visualizations

Set token based on hidden search and query result

juvenile
Loves-to-Learn

I have a hidden search. When I have a result I want to set the token based on that result, otherwise if I don't have any results I want to set the token to *. However, this does not work for me yet (the no results part with setting the token to all).

 

 

<search id="latest_product_id">
    <query>
        | mysearch
        | head 1 
        | fields product_id
    </query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <refresh>60</refresh>

    <depends>
        <condition token="some_token">*</condition>
    </depends>

    <done>
        <condition match="'job.resultCount'!= 0">
            <set token="latest_product_id">$result.product_id$</set>
        </condition>
        <condition match="'job.resultCount'== 0">
            <set token="latest_product_id">*</set>
        </condition>
    </done>
</search>

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Where is "all" coming from? It is not shown in your source listing. Also, the depends block you have shown is not part of valid SimpleXML. How are you using the latest_product_id token?

0 Karma

juvenile
Loves-to-Learn

I updated the search:

 

<search depends="some_other_token">
    <query>
        | mysearch id in $some_other_token$
        | head 1 
        | fields product_id
    </query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <refresh>60</refresh>

    <done>
        <condition match="'job.resultCount'!= 0">
            <set token="form.some_token">$result.product_id$</set>
        </condition>
        <condition match="'job.resultCount'== 0">
            <set token="form.some_token">*</set>
        </condition>
    </done>
</search>

 

The all is an option in the following multiselect

<input id="select_abc" type="multiselect" token="some_token" searchWhenChanged="true">
    <default>*</default>

    <prefix>(</prefix>
    <suffix>)</suffix>
    <valuePrefix>"</valuePrefix>
    <valueSuffix>"</valueSuffix>

    <choice value="*">All</choice>
    <search base="base_search">
        <query>
            | search to fill dropdown options
            | fields label, product_id
        </query>
    </search>
    <fieldForLabel>label</fieldForLabel>
    <fieldForValue>product_id</fieldForValue>

    <delimiter>,</delimiter>
</input>

So I want to set the value of the above multiselect (seom_token) on init and when another dropdown (some_other_token) changed. some_other_token is used in the search above.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...