Dashboards & Visualizations

database value in dropdown

vikas_gopal
Builder

Hi All,
I am preparing a dashboard where in I want to place a dropdown and I want to pick the following query output in the dropdown
"select book_type_code from fa_deprn_periods where period_name='JAN-09'" .
I have done the following and it is showing nothing in the dropbox.





<![CDATA[| dbquery "select book_type_code from fa_deprn_periods where period_name='JAN-09'"]]>



Tags (1)
0 Karma
1 Solution

vikas_gopal
Builder

I found another solution for this . Using Lookup you can achieve the same.
follow the following steps
1) Create a csv file in the following location "Splunk homeetcappsdbxlookups lets say the file is "user.csv".Make sure u must have some data in the CSV file.Else if u chk my code I am creating a CSV from dbquery with the help of | outputlookup command.
2) Create a new lookup from Settings--->Lookups-->Lookup table file here select the same csv file which u have created u can choose the same file name in the destination lets say the name is "vikaslookup".
3) Make sure u chkd the permissions it should be global.
4) Now open splunk and type the following code and that is it.

| dbquery "your database" "select abcdate as "Fromdate" from help"| outputlookup user.csv




<![CDATA[ | inputlookup vikaslookup ]]>

2013

View solution in original post

0 Karma

vikas_gopal
Builder

I found another solution for this . Using Lookup you can achieve the same.
follow the following steps
1) Create a csv file in the following location "Splunk homeetcappsdbxlookups lets say the file is "user.csv".Make sure u must have some data in the CSV file.Else if u chk my code I am creating a CSV from dbquery with the help of | outputlookup command.
2) Create a new lookup from Settings--->Lookups-->Lookup table file here select the same csv file which u have created u can choose the same file name in the destination lets say the name is "vikaslookup".
3) Make sure u chkd the permissions it should be global.
4) Now open splunk and type the following code and that is it.

| dbquery "your database" "select abcdate as "Fromdate" from help"| outputlookup user.csv




<![CDATA[ | inputlookup vikaslookup ]]>

2013

0 Karma

somesoni2
Revered Legend

Just to be sure, check the field name returned by query when ran manually in search is matching fieldForValue and fieldForLabel values, including case

0 Karma

vikas_gopal
Builder

Linu

While pasting this code in the above section I manually delete the database name , but it is there in the actual code and sql query is returning results that I have checked .
I do not have much idea about Cdata and I am not sure if I can use dbquery in CSDATA...Please suggest

0 Karma

linu1988
Champion

You need to follow proper case when creating the view definition, Proper capitalization where ever needed. Have given the sample for you.

<form>
<fieldset>
<input type="dropdown" searchWhenChanged="true" token="drop">
<populatingSearch fieldForValue="book_type_code" fieldForLabel="book_type_code">
 <![CDATA[| dbquery database_name "select book_type_code from fa_deprn_periods where period_name='JAN-09'"]]>
 </populatingSearch>
 </input>
 </fieldset>
 </form>

Thanks

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!

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...