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

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...