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!

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...

[Live Demo] Watch SOC transformation in action with the reimagined Splunk Enterprise ...

Overwhelmed SOC? Splunk ES Has Your Back Tool sprawl, alert fatigue, and endless context switching are making ...

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...