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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...