Dashboards & Visualizations

Run search in a dashboard if a token has a value in it

jhmoen
New Member

I have a dashboard with textbox used for a search. I would think this is simple but don't see any examples of this out there. I only want to run the dashboard query if the token (textbox) has a value in it. If it does, then run the query, which does work on its own. But if not, then don't run it.

|eval result = if(isnull($LotNumber$),"", sourcetype=xyx |search $LotNumber$) | table result
0 Karma

cmerriman
Super Champion

is your textbox input (token) in your query? The search shouldn't run if it is waiting for a token. the panel would say "Waiting for Input" or something like that until a token was submitted via textbox. In your search, you would just need something like field=$LotNumber|s$

0 Karma

jhmoen
New Member

It is in my query. I simply want:
sourcetype=xyz |search $LotNumber$
This works, but when the page first loads, I get all the results from sourcetype=xyz. I basically want it to wait for the input, then do the search. Likewise, once one is searched, if you were to clear out the textbox and click submit, you would get nothing again (like page load)

0 Karma

javanzato
New Member

Just in case you never figured this out - you should edit the source so that instead of

<search>
.....

it should be

<search depends="$yourtoken$">
....
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...