Getting Data In

How to group the list under one catogery/checkbox instead of displaying the entire list in drop down?

navd
New Member

Hi ,
I have the following sources in splunk , so I wanted to group similar ones under one category/checkbox instead of displaying the entire list in drop down

source= /var/log/message.log
source=/var/log/message1.log
source=/var/log/message2.log
source=/var/log/tmp/rmps.log

So, based on the above sources, I want to achieve this:
alt text

0 Karma
1 Solution

niketn
Legend

@navd, based on the details provided you can try a dropdown like the following where token passed as base search filter for source will be $tokSource$. I have used Dropdown <change> event handler with <condition> to set the token value as required based on which option is selected.

PS: Based on sample data I have used wildcard (asterisk) match for message* logs. But you can change it as per what you need. If you are on Splunk 6.6 or higher you can use IN clause based token for source to match multiple patters/values.

<input type="dropdown" token="tokSourceGroup" searchWhenChanged="true">
  <label>Select Source Group</label>
  <choice value="*">All</choice>
  <choice value="rmps">rmps</choice>
  <choice value="messages">messages</choice>
  <change>
    <condition value="messages">
      <set token="tokSource">source="/var/log/message*.log"</set>
    </condition>
    <condition value="rmps">
      <set token="tokSource">source="/var/log/tmp/rmps.log"</set>
    </condition>
    <condition label="All">
      <set token="tokSource">source=*</set>
    </condition>
  </change>
  <default>*</default>
</input>

Please try the following run anywhere dashboard to test:

<form>
  <label>Group Source in Dropdown Options</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokSourceGroup" searchWhenChanged="true">
      <label>Select Source Group</label>
      <choice value="*">All</choice>
      <choice value="rmps">rmps</choice>
      <choice value="messages">messages</choice>
      <change>
        <condition value="messages">
          <set token="tokSource">source="/var/log/message*.log"</set>
        </condition>
        <condition value="rmps">
          <set token="tokSource">source="/var/log/tmp/rmps.log"</set>
        </condition>
        <condition label="All">
          <set token="tokSource">source=*</set>
        </condition>
      </change>
      <default>*</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
            | eval source="/var/log/message.log;/var/log/message1.log;/var/log/message2.log;/var/log/tmp/rmps.log"
            | makemv source delim=";"
            | mvexpand source
            | search $tokSource$
          </query>
        </search>
      </table>
    </panel>
  </row>
</form>

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

dflodstrom
Builder

Can you include the code for your dropdown as it currently is? If this list is being populated dynamically the solution will be different than if you're supplying a static list of options.

0 Karma

niketn
Legend

@navd, based on the details provided you can try a dropdown like the following where token passed as base search filter for source will be $tokSource$. I have used Dropdown <change> event handler with <condition> to set the token value as required based on which option is selected.

PS: Based on sample data I have used wildcard (asterisk) match for message* logs. But you can change it as per what you need. If you are on Splunk 6.6 or higher you can use IN clause based token for source to match multiple patters/values.

<input type="dropdown" token="tokSourceGroup" searchWhenChanged="true">
  <label>Select Source Group</label>
  <choice value="*">All</choice>
  <choice value="rmps">rmps</choice>
  <choice value="messages">messages</choice>
  <change>
    <condition value="messages">
      <set token="tokSource">source="/var/log/message*.log"</set>
    </condition>
    <condition value="rmps">
      <set token="tokSource">source="/var/log/tmp/rmps.log"</set>
    </condition>
    <condition label="All">
      <set token="tokSource">source=*</set>
    </condition>
  </change>
  <default>*</default>
</input>

Please try the following run anywhere dashboard to test:

<form>
  <label>Group Source in Dropdown Options</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokSourceGroup" searchWhenChanged="true">
      <label>Select Source Group</label>
      <choice value="*">All</choice>
      <choice value="rmps">rmps</choice>
      <choice value="messages">messages</choice>
      <change>
        <condition value="messages">
          <set token="tokSource">source="/var/log/message*.log"</set>
        </condition>
        <condition value="rmps">
          <set token="tokSource">source="/var/log/tmp/rmps.log"</set>
        </condition>
        <condition label="All">
          <set token="tokSource">source=*</set>
        </condition>
      </change>
      <default>*</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
            | eval source="/var/log/message.log;/var/log/message1.log;/var/log/message2.log;/var/log/tmp/rmps.log"
            | makemv source delim=";"
            | mvexpand source
            | search $tokSource$
          </query>
        </search>
      </table>
    </panel>
  </row>
</form>

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

vikashperiwal
Path Finder

Hi @niketnilay ,

to this is it possible in chart, when "ALL" is selected and ALL has static values (A,B,C,D), and time chart is filtered by values, it should not show A,B,C,D in legends, rather should show only "Alphabet" in chart.

| timechart span=15m avg(x) as "session_current" by values

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...