Dashboards & Visualizations

How to limit the 'All' option to what query actually returns and not for * entries for targetAppAlternateId

sb01splunk
Explorer

I would like to be able to limit the 'All' option to what my query actually returns and not for * entries for targetAppAlternateId.

 

<form theme="dark">
  <label>Logins</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>targetAppAlternateId</fieldForLabel>
      <fieldForValue>targetAppAlternateId</fieldForValue>
      <search>
        <query>index=myIndex targetAppAlternateId="App1.*" OR targetAppAlternateId="App2" | dedup targetAppAlternateId
| sort by targetAppAlternateId</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
    </input>

 

Any help would be greatly appreciated. 

Labels (2)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@sb01splunk 

Can you Please try below example?

<form>
  <label>Limit All Option in Search</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>targetAppAlternateId</fieldForLabel>
      <fieldForValue>targetAppAlternateId</fieldForValue>
      <search>
        <query>index=myIndex targetAppAlternateId="App1.*" OR targetAppAlternateId="App2" | dedup targetAppAlternateId
| sort by targetAppAlternateId</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
      <change>
        <condition match="$value$==&quot;*&quot;">
          <set token="condition_tkn">targetAppAlternateId="App1.*" OR targetAppAlternateId="App2"</set>
        </condition>
        <condition>
          <set token="condition_tkn">targetAppAlternateId="$value$"</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        $myApp$ <br/>
        $condition_tkn$
      </html>
    </panel>
  </row>
</form>

 

My Sample XML :

 

<form>
  <label>Limit All Option in Search</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
      <search>
        <query>index=_internal sourcetype=splunk_w* OR sourcetype=splunkd | stats count by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
      <change>
        <condition match="$value$==&quot;*&quot;">
          <set token="condition_tkn">sourcetype=splunk_w* OR sourcetype=splunkd</set>
        </condition>
        <condition>
          <set token="condition_tkn">sourcetype="$value$"</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        $myApp$ <br/>
        $condition_tkn$
      </html>
    </panel>
  </row>
</form>

 

Screenshot 2022-04-12 at 10.01.19 AM.png

 

Screenshot 2022-04-12 at 10.01.30 AM.png

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@sb01splunk 

Can you Please try below example?

<form>
  <label>Limit All Option in Search</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>targetAppAlternateId</fieldForLabel>
      <fieldForValue>targetAppAlternateId</fieldForValue>
      <search>
        <query>index=myIndex targetAppAlternateId="App1.*" OR targetAppAlternateId="App2" | dedup targetAppAlternateId
| sort by targetAppAlternateId</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
      <change>
        <condition match="$value$==&quot;*&quot;">
          <set token="condition_tkn">targetAppAlternateId="App1.*" OR targetAppAlternateId="App2"</set>
        </condition>
        <condition>
          <set token="condition_tkn">targetAppAlternateId="$value$"</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        $myApp$ <br/>
        $condition_tkn$
      </html>
    </panel>
  </row>
</form>

 

My Sample XML :

 

<form>
  <label>Limit All Option in Search</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
      <search>
        <query>index=_internal sourcetype=splunk_w* OR sourcetype=splunkd | stats count by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
      <change>
        <condition match="$value$==&quot;*&quot;">
          <set token="condition_tkn">sourcetype=splunk_w* OR sourcetype=splunkd</set>
        </condition>
        <condition>
          <set token="condition_tkn">sourcetype="$value$"</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        $myApp$ <br/>
        $condition_tkn$
      </html>
    </panel>
  </row>
</form>

 

Screenshot 2022-04-12 at 10.01.19 AM.png

 

Screenshot 2022-04-12 at 10.01.30 AM.png

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma

sb01splunk
Explorer

I am sure I am doing something wrong but it is not working for me.  Below is the full sample I am testing:

<form theme="dark">
  <label>Logins</label>
  <fieldset submitButton="false">
    <input type="time" token="selectTime">
      <label>Time:</label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="myApp">
      <label>Application:</label>
      <fieldForLabel>targetAppAlternateId</fieldForLabel>
      <fieldForValue>targetAppAlternateId</fieldForValue>
      <search>
        <query>index=myIndex targetAppAlternateId="App1.*" OR targetAppAlternateId="App2" | dedup targetAppAlternateId
| sort by targetAppAlternateId</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <choice value="*">All</choice>
      <change>
        <condition match="$value$==&quot;*&quot;">
          <set token="condition_tkn">targetAppAlternateId="App1.*" OR targetAppAlternateId="App2"</set>
        </condition>
        <condition>
          <set token="condition_tkn">targetAppAlternateId="$value$"</set>
        </condition>
      </change>      
    </input>
  </fieldset>
  <row>
    <panel>
      <chart>
        <search>
          <query>index=myIndex targetAppAlternateId="$myApp$"
| stats count by targetAppAlternateId</query>
          <earliest>$selectTime.earliest$</earliest>
          <latest>$selectTime.latest$</latest>
          <refresh>1m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.chart">pie</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
  </row>
</form>
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@sb01splunk 

 

Just update your pie chart search with below one.  🙂 

<query>index=myIndex $condition_tkn$
| stats count by targetAppAlternateId</query>

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma

sb01splunk
Explorer

Thank you so much!  Works perfectly!

0 Karma
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...