Splunk Search

Need to create a Dashboard which can select multiple fields based on user selection of checkbox/ radio button.

jithinmathew
Explorer

Hi all,

I Need to create a Dashboard which can select multiple extracted fields based on user selection of checkbox/ radio button.

alt text

For example, I want the user to be able to search with both fields ServiceID AND Username. I currently have the single search functionality working but I cant seem to think of how I will pass multiple fields.

Will greatly appreciate any help with this.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi jithinmathew,
I had a similar problem and I solved it creating a filter for each field.

In addition you have to manage the problem that not all the fields had 100% values so if you use "All" () as default for all fields you exclude all the events that haven't one of the fields.
To manage this problem, you have to use ad default something like: `Username=
OR NOT Username=*`
Bye.
Giuseppe

0 Karma

renjith_nair
Legend

@jithinmathew,

Are you looking for something similar?

<form>
  <label>Radio Button</label>
  <fieldset submitButton="false">
    <input type="radio" token="sourcetype">
      <label>Sourc e Type</label>
      <choice value="splunkd">SPLUNKD</choice>
      <choice value="kvstore">KVSTORE</choice>
      <choice value="audittrail">AUDIT TRIAL</choice>
    </input>
    <input type="text" token="searchbox">
      <label>Search Box</label>
      <default>$sourcetype$</default>
      <initialValue>$sourcetype$</initialValue>
    </input>
    <input type="radio" token="index" searchWhenChanged="true">
      <label>Include Index In Group By?</label>
      <choice value="index">Yes</choice>
      <choice value="">No</choice>
      <prefix>, </prefix>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Value from Search Filter : $sourcetype$</title>
      <table>
        <search>
          <query>index=_* sourcetype=$sourcetype$|stats count by sourcetype $index$</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
Happy Splunking!
0 Karma

jithinmathew
Explorer

Hmm no, for example, I want the user to be able to search both splunkd and KVSTORE at the same time instead of one each.

0 Karma

renjith_nair
Legend

@jithinmathew,
That's simple, just change the radio button to checkbox

<form>
  <label>Radio Button</label>
  <fieldset submitButton="false">
    <input type="checkbox" token="sourcetype">
      <label>Sourc e Type</label>
      <choice value="splunkd">SPLUNKD</choice>
      <choice value="kvstore">KVSTORE</choice>
      <choice value="audittrail">AUDIT TRIAL</choice>
      <valuePrefix>sourcetype="</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter> OR </delimiter>
      <prefix>(</prefix>
      <suffix>)</suffix>
    </input>
    <input type="text" token="searchbox">
      <label>Search Box</label>
      <default>$sourcetype$</default>
      <initialValue>$sourcetype$</initialValue>
    </input>
    <input type="radio" token="index" searchWhenChanged="true">
      <label>Include Index In Group By?</label>
      <choice value="index">Yes</choice>
      <choice value="">No</choice>
      <prefix>, </prefix>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Value from Search Filter : $sourcetype$</title>
      <table>
        <search>
          <query>index=_* $sourcetype$|stats count by sourcetype $index$</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...