Deployment Architecture

Splunk DB Connect 1: How to create a search form that runs a dbquery when username is a variable?

abovebeyond
Communicator

Hi,

I'm trying to create a search form that runs a dbquery when username is a variable.

I tried with this code without a success:

<form>
  <label> Users </label>
  <description/>

  <searchTemplate>
| dbquery "testdb" "select * from [vw_Getusers] 
Where username=$username$"
  </searchTemplate>


  <fieldset autoRun="True">


    <input type="text" token="username">
      <label>username</label>
      <default>admin</default>
      <suffix>*</suffix>
    </input>


    <input type="time" searchWhenChanged="true">
      <default>
        <earliestTime>-24h@h</earliestTime>
        <latestTime>now</latestTime>
      </default>
    </input>

  </fieldset>

  <row>
    <panel>

      <table>
        <option name="showPager">true</option>
        <option name="count">20</option>
      </table>
    </panel>
  </row>
</form>

Where is it failing?
Thanks

0 Karma
1 Solution

abovebeyond
Communicator

now its working, using the following code

<form>
  <label> Users </label>
  <description/>
  <fieldset>

   <input type="text" token="username">
     <label>Enter the value of Username</label>
   </input>
  </fieldset>

   <searchTemplate>
 | dbquery "testdb" "selectfrom [vw_Getusers] 
Where username='$username$'" 
     order by id desc 
   </searchTemplate>

  <row>
    <panel>
      <table>
        <option name="showPager">true</option>
        <option name="count">20</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

0 Karma

abovebeyond
Communicator

now its working, using the following code

<form>
  <label> Users </label>
  <description/>
  <fieldset>

   <input type="text" token="username">
     <label>Enter the value of Username</label>
   </input>
  </fieldset>

   <searchTemplate>
 | dbquery "testdb" "selectfrom [vw_Getusers] 
Where username='$username$'" 
     order by id desc 
   </searchTemplate>

  <row>
    <panel>
      <table>
        <option name="showPager">true</option>
        <option name="count">20</option>
      </table>
    </panel>
  </row>
</form>
0 Karma
Get Updates on the Splunk Community!

BSides Splunk 2022 - The Call for Papers is now Open!

TLDR; Main Site: https://bsidessplunk.com CFP Site: https://bsidessplunk.com/cfp CFP Opens: December 15th, ...

Sending Metrics to Splunk Enterprise With the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...

What's New in Splunk Cloud Platform 9.0.2208?!

Howdy!  We are happy to share the newest updates in Splunk Cloud Platform 9.0.2208! Analysts can benefit ...