Splunk Search

Dashboard Studio Dropdown default value from lookup table

splunkuser320
Path Finder

I am trying to replace default value of drop down with all the values from a column in lookup table

Example:

Lookup table 

Namelog_group
Name 1Log1
Name 2log 2
Name 3log3

 

I need drop down default taken as log1,log2,log3

Labels (1)
0 Karma
1 Solution

dural_yyz
Motivator

Ok this is ugly but should be functionable.  After researching I wasn't able to find a method to dynamically assign the default value, but you can default to the first value of the search result.

Source Table

NameValue
Name 01Value 01
Name 02value 02
Name 03value03
Name 04Value04

 

Set your data source to pull from a search designed like the following - modify for your needs.

| inputlookup input_test_values.csv 
| stats values(Value) as Value
| format
| rename search as Value
| eval Name="All"
| table Name Value
| append
[| inputlookup input_test_values.csv
| table Name Value ]

Search Output:

NameValue
All( ( ( Value="Value 01" OR Value="Value04" OR Value="value 02" OR Value="value03" ) ) )
Name 01Value 01
Name 02value 02
Name 03value03
Name 04Value04

 

Your inputs config panel to the right should be able to select "First Value" as the default.  The search as written can display "All" in the drop down while dynamically building the first value based upon the contents of the lookup no matter how many times it is edited.  

The way I have written makes the first value very easy to drop into a subsequent search string.  Your needs may vary so you can play with the format command to get that output as you need it specifically.

View solution in original post

0 Karma

yuanliu
SplunkTrust
SplunkTrust

I need drop down default taken as log1,log2,log3

As @dural_yyz hinted at, the actual solution depends very much on how you will use the input token in search.  If you want the comma delimited list as part of IN function, you can just use appendpipe.

 

| inputlookup mylookup
| appendpipe
    [stats values(log_group) as log_group
    | eval Name = "Any", log_group = mvjoin(log_group, ",")]

 

You get

Namelog_group
Name 1Log1
Name 2log2
Name 3log3
Anylog1,log2,log3

 

 

Tags (2)
0 Karma

dural_yyz
Motivator

Ok this is ugly but should be functionable.  After researching I wasn't able to find a method to dynamically assign the default value, but you can default to the first value of the search result.

Source Table

NameValue
Name 01Value 01
Name 02value 02
Name 03value03
Name 04Value04

 

Set your data source to pull from a search designed like the following - modify for your needs.

| inputlookup input_test_values.csv 
| stats values(Value) as Value
| format
| rename search as Value
| eval Name="All"
| table Name Value
| append
[| inputlookup input_test_values.csv
| table Name Value ]

Search Output:

NameValue
All( ( ( Value="Value 01" OR Value="Value04" OR Value="value 02" OR Value="value03" ) ) )
Name 01Value 01
Name 02value 02
Name 03value03
Name 04Value04

 

Your inputs config panel to the right should be able to select "First Value" as the default.  The search as written can display "All" in the drop down while dynamically building the first value based upon the contents of the lookup no matter how many times it is edited.  

The way I have written makes the first value very easy to drop into a subsequent search string.  Your needs may vary so you can play with the format command to get that output as you need it specifically.

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...