All Apps and Add-ons

How to populate a drop-down list from a search?

Federica_92
Communicator

Hi everyone,

I'm trying with the splunk framework to take results from a search and show them on a drop-down menu. I have two examples, but both of them don't work and produce the same errors. I have tested the search in the Search and Reporting App and they produce a single result for each event.
The error is: "Duplicate labels causing conflict"

example 1:
My code is very simple:
This is what there is in the block section:

   {% dropdown id="drop-list1" managerid="mysearch-tree-exec-d"  default=" "  value="$path$"|token_safe %}

And this is the code in the js section:

  new SearchManager_tree_e_d({
                    id: "mysearch-tree-exec-d",
                    search:("host=path sourcetype=__singleline source=http-stream earliest=-10m")
            });

example 2:

{% dropdown id="drop-list2" managerid="mysearch-log"  default=" "  value="$sourcename$"|token_safe %}

 new SearchManager({
                    id: "mysearch-log",
                    search: "index=main source=* | dedup source | fields source"
                }); take all the different source

please, could someone help me?

0 Karma
1 Solution

lquinn
Contributor

Try this:

{dropdown id="drop-list2" managerid="mysearch-log" default="" labelField="source" valueField="source" value="$sourcename$"|token_safe %}

Specifying the value and label field tells Splunk which field you want to appear in your dropdown.

View solution in original post

0 Karma

lquinn
Contributor

Try this:

{dropdown id="drop-list2" managerid="mysearch-log" default="" labelField="source" valueField="source" value="$sourcename$"|token_safe %}

Specifying the value and label field tells Splunk which field you want to appear in your dropdown.

0 Karma

Federica_92
Communicator

Thank you, in my first case works, in my second one not:

  {% dropdown id="drop-list2" managerid="mysearch-tree-exec-d"  default=" " labelField="source" valueField="source" value="$path$"|token_safe %}

any ideas?

0 Karma

Federica_92
Communicator
search:("host=path sourcetype=__singleline source=http-stream earliest=-10m | fields path") all my host, so 
{% dropdown id="drop-list2" managerid="mysearch-tree-exec-d"  default=" " labelField="host" valueField="host" value="$path$"|token_safe %} 

But doesn't work

0 Karma

lquinn
Contributor

Are you sure you are looking for host? Havn't you specified host to be path at the beginning of your search? If you run this search can you see all the values that you want to be displayed? What field name are they under?

0 Karma

Federica_92
Communicator

Ok, I think I got the problem, I'm going to try to extract the field path with the rex epression, Now I try

0 Karma

Federica_92
Communicator

As well I have tried with labelField="path"

0 Karma

lquinn
Contributor

Which field are you trying to display for this one?

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 ...