Splunk Search

Run search according to user inputs(If/Else conditions)

john
Communicator

Hi,

I want to run search queries depend on user input,ie what user selecting from dropdown.

eg:if user choose 1 from dropdown
run a search
2 from dropdown run another search
is this possible

iam looking sumthing like this
if(1)
run 1st search

if(2)

run 2nd search

please help.

Tags (1)

woodcock
Esteemed Legend

Like this:

<form>
  <label>Two search example</label>
  <description>A question in answers.splunk.com</description>
  <fieldset autoRun="true" submitButton="false">
    <input type="dropdown" token="search_string_tok1">
      <label>Hard-Coded Searches</label>
      <choice value="earliest=0 latest=now() | head 5">last 5 events</choice>
      <choice value="earliest=0 latest=now() | head 10">last 10 events</choice>
      <default>last 5 events</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>User-selected search</title>
        <searchString>$search_string_tok1$</searchString>
        <option name="list.drilldown">full</option>
        <option name="list.wrap">1</option>
        <option name="maxLines">5</option>
        <option name="raw.drilldown">full</option>
        <option name="rowNumbers">false</option>
        <option name="table.drilldown">all</option>
        <option name="table.wrap">1</option>
        <option name="type">list</option>
        <option name="wrap">true</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="count">10</option>
      </table>
    </panel>
  </row>
</form>
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...