Dashboards & Visualizations

submit button based on env name/value

nithys
Communicator

Thanks for the solution which worked When i select the data entity and the time  and hit the submit button with below query ...But without selecting the env test or prod the query get search based on the default dropdown applies to the query if it is test  index as "np-ap" and sets stageToken as test.

I want  the submit button to work even for the env selection ...along with data entity and date


index="np-ap" AND source="--a-test"
<query>index=$indexToken$ AND source="-a-$stageToken$"

 

<form version="1.1" theme="dark">
<label> stats</label>
<fieldset submitButton="true">
<input type="dropdown" token="indexToken1">
<label>Environment</label>
<choice value="pd-ap,prod">PROD</choice>
<choice value="np-ap,test">TEST</choice>
<change>
<eval token="stageToken">mvindex(split($value$,","),1)</eval>
<eval token="indexToken">mvindex(split($value$,","),0)</eval>
</change>
<default>np-ap,test</default>
</input>
<input type="dropdown" token="entityToken">
<label>Data Entity</label>
<choice value="aa">aa</choice>
<choice value="bb">bb</choice>
<choice value="cc">cc</choice>
<choice value="dd">dd</choice>
<choice value="ee">ee</choice>
<choice value="ff">ff</choice>
<default>aa</default>
</input>
<input type="time" token="timeToken" searchWhenChanged="false">
<label>Time</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
</fieldset>
<row>
<panel>
<html id="APIStats">
<style>
#user{
text-align:center;
color:#BFFF00;
}
</style>
<h2 id="user">API</h2>
</html>
</panel>
</row>
<row>
<panel>
<table>
<title>Unique</title>
<search>
<query>index=$indexToken$ AND source="-a-$stageToken$" 

| stats count </query>
<earliest>$timeToken.earliest$</earliest>
<latest>$timeToken.latest$</latest>
</search>
<option name="drilldown">none</option>
<option name="refresh.display">progressbar</option>
</table>
</panel>

</row>

</form>

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Create an init block which sets the default values for stageToken and indexToken

<init>
<set token="stageToken">test</set>
<set token="indexToken">ap</set>
</init>
0 Karma

nithys
Communicator

Hi,
If i add init getting below error
Still on the background without submitting "submit" button it runs the query of the env and fetch the result
Screenshot 2024-10-27 at 6.45.31 PM.png

0 Karma

dural_yyz
Motivator

Add it outside the fieldset grouping.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...