Dashboards & Visualizations

Splunk dashboard filter by user input with multiple value from user command field

elend
Communicator

Hello there, im creating a #Splunk Dashboards table that utilized to monitor user command. And i want to make it flexible and dynamic to view the table by user inpu
For now i already create this search string as table that can apply filter by Find Command and Exclude Command, but it only accept single string as filter.

 

index=os_linux sourcetype="bash_history"
| dedup timestamp
| fields _time process, dest, user_name
| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT process="$exclude_command$"
| table _time user_name process dest
| rename dest as hostname, process as user_command
| sort -_time

 

 

It is possible to make the exclude_command accept multiple values with some separator? or another option recomended.

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You need to split process up if you want to treat the parts of the command line up as separate things. Try this

| eval parts=split(process," ")
| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT parts IN ($exclude_command$)

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Depending on how you have set up your exclude_command token (which you haven't shared with us yet), you could try something like this

| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT process IN $exclude_command$
0 Karma

elend
Communicator

sorry for lack of information @ITWhisperer . Here's the full information for the dashboard:

 

<panel>
      <title>Logging Command History by User</title>
      <input type="text" token="drilldown_command" searchWhenChanged="true">
        <label>Find Command</label>
        <default>*</default>
      </input>
      <input type="text" token="exclude_command" searchWhenChanged="true">
        <label>Exclude Command</label>
        <default>NULL</default>
      </input>
      <table>
        <search>
          <query>index=unix_os sourcetype="bash_history"
| dedup timestamp 
| fields _time process, dest, user_name
| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT process="$exclude_command$"
| table _time user_name process dest
| rename dest as hostname, process as user_command
| sort -_time</query>
          <earliest>$time_global.earliest$</earliest>
          <latest>$time_global.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">10</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">false</option>
      </table>
    </panel>

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT process IN ($exclude_command$)

Note that your user will have to enter the terms as quoted strings delimited by commas e.g. "commandA","commandB"

0 Karma

elend
Communicator

With that option, exclude input was ignored.
But if with this one changes it can apply exclude input only one value.

| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT process IN (*$exclude_command$*)

 If search terms as quoted strings delimited by commas e.g. "commandA","commandB" it give no result:
quoted-exclude.jpegsingle-exclude.jpeg

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What is with the asterisks? Remove them and try again

0 Karma

elend
Communicator

if I remove the asterix, Exclude Command input ignore any input even single input will ignored so it only show table from find command. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you open the search (from the dashboard table) in a separate table and share the search being used?

0 Karma

elend
Communicator

Here's the output from your provided search query, it ignoring the exclude input.
output.jpeg

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need to split process up if you want to treat the parts of the command line up as separate things. Try this

| eval parts=split(process," ")
| search user_name=$user_name$ dest=$host_name$ process="$user_command$" NOT parts IN ($exclude_command$)

elend
Communicator

*

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...