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
Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

Stay Connected: Your Guide to October Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...