Dashboards & Visualizations

Setting search term based on dropdown selection in dashboard

iceburg47
Explorer

I have a dashboard with thre saved searches for three server environments. The searches only differ based on which environment the search matches. What I want to do is make it so that a dropdown can be used to set a search term to specify the environment to search against rather than having a separate saved search for each environment. The environment an entry came from is determined by a substring of the host name that exists for test or beta environments but not production.

For example I would want to set the following search terms based on the selected value

Test is selected: "host=*Test*"
Beta is selected: "host=*Beta*"
Test is selected: "NOT host=*Test* NOT host=*Beta*"

I can probably do the matching more efficiently, but that's another mater.

Here is what my current saved search looks like for the test environment:

source="C:\\Logs\\*.log"
     host=*Test* 
     level=Error 
|cluster showcount=t field=ExceptionStackTrace t=0.9 
|  sort - cluster_count 
|  table ExceptionType ExceptionMessage ExceptionStackTrace cluster_count

How can I make my search reference the selected dropdown value?

I created dropdown with the following XML:

<input type="dropdown" token="_environmentSelected" searchWhenChanged="true">
    <label>Environment</label>
    <choice value="host=*UTT*">Test</choice>
    <choice value="host=*UTS*">Stage</choice>
    <choice value="NOT host=*UT*">Production</choice>
</input>

How do I reference the selected dropdown value in the search?

0 Karma
1 Solution

dolivasoh
Contributor

Use tokens, See in your XML above it says token="_environmentSelected" so in your search where you want the string to appear just place $_environmentSelected$

View solution in original post

iceburg47
Explorer

P.S. I'm not sure why "5." is appearing in two of my code snippets. Please ignore that.

0 Karma

dolivasoh
Contributor

Use tokens, See in your XML above it says token="_environmentSelected" so in your search where you want the string to appear just place $_environmentSelected$

iceburg47
Explorer

Thank you so much. I feel rather silly, I had missed surrounding the token name with $. Thanks again!

dolivasoh
Contributor

No Problem. Happy Splunking!

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...