<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: dbquery and variables in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198508#M20676</link>
    <description>&lt;P&gt;The only way I can think of to use variables in a query is to use tokens within the query. What kind of dashboard are you using this with? (simplexml advancedxml, javascript, django) etc.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2014 22:32:33 GMT</pubDate>
    <dc:creator>aelliott</dc:creator>
    <dc:date>2014-01-09T22:32:33Z</dc:date>
    <item>
      <title>dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198499#M20667</link>
      <description>&lt;P&gt;Can I pass any kind of variable to dbquery through splunk?  It demands being the first search command: "Error in 'dbquery' command: This command must be the first command of a search."&lt;/P&gt;

&lt;P&gt;I would like to accomplish a search in splunk that then passed data to dbquery so I can use it in the select statement.  I know this can be done in a form, but I want to do it in a query that is generated a the dashboard.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2014 21:26:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198499#M20667</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-08T21:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198500#M20668</link>
      <description>&lt;P&gt;Looks like you can create your variables using eval and use them within the query with dollar signs surrounding.. similar to this query &lt;/P&gt;

&lt;P&gt;index=_internal | stats dc(source) dc(sourcetype) | rename dc(source) AS dcs dc(sourcetype) AS dct | dboutput database=mysql type=sql "INSERT INTO t1 (a, b) VALUES ($dct$, $dcs$)"&lt;/P&gt;

&lt;P&gt;within the documentation&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/DBX/1.1.1/DeployDBX/Commands"&gt;http://docs.splunk.com/Documentation/DBX/1.1.1/DeployDBX/Commands&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2014 22:46:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198500#M20668</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-08T22:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198501#M20669</link>
      <description>&lt;P&gt;I see the article, but the examples given do not work for me.  As I mentioned, I get an error if dbquery is not the first search paramter:&lt;BR /&gt;
"Error in 'dbquery' command: This command must be the first command of a search."&lt;BR /&gt;
So, the example in the documentation: &lt;BR /&gt;
index=_internal | dbquery ASSET_DB "SELECT id,name, ip_address,owner,last_update FROM hosts WHERE active = 1" limit=25&lt;BR /&gt;
Just plainly does not work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:36:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198501#M20669</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2020-09-28T15:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198502#M20670</link>
      <description>&lt;P&gt;what if you leave off the index=_internal ?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 14:26:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198502#M20670</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-09T14:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198503#M20671</link>
      <description>&lt;P&gt;If I removed that my queries work. (using my own database of course, not ASSET_DB).&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 17:40:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198503#M20671</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-09T17:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198504#M20672</link>
      <description>&lt;P&gt;If you were to use a dbquery command in conjunction with another search, it would be like running the dbquery command many times for each result in the search. Is this what functionality you want?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 17:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198504#M20672</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-09T17:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198505#M20673</link>
      <description>&lt;P&gt;|dbquery should be the first command, there shouldn't be any index=_internal or any other statement at all&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 18:19:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198505#M20673</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-09T18:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198506#M20674</link>
      <description>&lt;P&gt;aelliot&amp;gt; No, actually, i would like to pass data to a single dbquery.  In this case the command would return one value for one query.&lt;BR /&gt;
linu1988&amp;gt; Are you implying their documentation is wrong in the example provided?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 21:58:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198506#M20674</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-09T21:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198507#M20675</link>
      <description>&lt;P&gt;Yep, pretty sure. Even if they make it right, index=_internal makes no sense at all.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 22:04:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198507#M20675</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-09T22:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198508#M20676</link>
      <description>&lt;P&gt;The only way I can think of to use variables in a query is to use tokens within the query. What kind of dashboard are you using this with? (simplexml advancedxml, javascript, django) etc.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 22:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198508#M20676</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-09T22:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198509#M20677</link>
      <description>&lt;P&gt;if you want it to be a dashboard variable why do you want it in the search? you can have some pulldown modules or textbox then with submit button form your query to run. i dont find any difficulty in this.&lt;/P&gt;

&lt;P&gt;|dbquery database=xxx "select $var1,$var2 from table"&lt;/P&gt;

&lt;P&gt;$var1,$var2 can be selected from pulldown or textbox..&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2014 22:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198509#M20677</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-09T22:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198510#M20678</link>
      <description>&lt;P&gt;I am using advanced XML, and I don't want them to select the data.  That is because the data is their username.  I can build customized dashboards, using custom queries from a database that uses their username (we have common usernames in apps).  So a person can go to "My dashboard" and it will populate with queries that are relevant to their username, which is gathered from a splunk command.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 16:26:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198510#M20678</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-17T16:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198511#M20679</link>
      <description>&lt;P&gt;yes it is possible. I have done a similar thing where it will find the logged in user and log their activity. You can maintain a lookup or pass them directly to the query by finding the logged in user. Apply the intention to pass it to dbquery. This is my assumtion&lt;/P&gt;

&lt;P&gt;|rest /services/authentication/users splunk_server=local | search [| rest /services/authentication/current-context splunk_server=local | rename username as title | fields title]&lt;/P&gt;

&lt;P&gt;this will give you the logged user.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:40:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198511#M20679</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2020-09-28T15:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198512#M20680</link>
      <description>&lt;P&gt;I can get the username. Just not sure I understand this part: Apply the intention to pass it to dbquery.  That is my struggle inside a search command. (or perhaps it has to be a dashboard?)&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 18:31:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198512#M20680</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-17T18:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198513#M20681</link>
      <description>&lt;P&gt;yes as per your previous post you mentioned you are advanced xml i.e. on dashboard right!?&lt;/P&gt;

&lt;P&gt;Follow some examples in sideview utils/splunk UI examples how to pass the value from parent to child module. You can get the user name then pass it as a variable to your |dbquery...&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 18:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198513#M20681</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-17T18:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198514#M20682</link>
      <description>&lt;P&gt;in dbx app you also have the same implementation where you choose the database and then write the query. it is kinda same what you are looking for..&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 18:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198514#M20682</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-17T18:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198515#M20683</link>
      <description>&lt;P&gt;I will check out passing the values in the dashboard. thanks for the tip!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 19:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198515#M20683</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2014-01-17T19:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198516#M20684</link>
      <description>&lt;P&gt;I downvoted this post because that doesn't work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 15:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198516#M20684</guid>
      <dc:creator>arlakathena</dc:creator>
      <dc:date>2019-04-22T15:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery and variables</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198517#M20685</link>
      <description>&lt;P&gt;@arlakathena rather than &lt;A href="https://docs.splunk.com/Documentation/Splunkbase/splunkbase/Answers/Voting#Downvoting"&gt;down-voting&lt;/A&gt; a 4 year old post, I would request you to post a new question with the issue you are facing, along with other required details, so that Community members can assist you better. &lt;/P&gt;

&lt;P&gt;As you might be aware dbquery is no longer used in db connect. With the latest version you should be using &lt;A href="https://docs.splunk.com/Documentation/DBX/latest/DeployDBX/Commands"&gt;dbxquery&lt;/A&gt; instead.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 17:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/dbquery-and-variables/m-p/198517#M20685</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-04-22T17:01:15Z</dc:date>
    </item>
  </channel>
</rss>

