Dashboards & Visualizations

help to add submitbutton in panel

jip31
Motivator

hi

is it possible to use a submitButton in a panel?
I would like to add it in the xml below
thanks

      <input type="text" token="tok_filterhost" searchWhenChanged="true">
        <label>Filter by hostname</label>
        <default>*</default>
        <initialValue>*</initialValue>
      </input>
0 Karma
1 Solution

dmarling
Builder

This is unfortunately not supported natively in splunk. There are some work arounds that you can find on answers. Here's some suggested answers to review:

https://answers.splunk.com/answers/346916/submit-button-per-panel-in-simple-xml.html

https://answers.splunk.com/answers/683916/submit-button-inside-a-panel-is-not-working.html

If this comment/answer was helpful, please up vote it. Thank you.

View solution in original post

0 Karma

vnravikumar
Champion

Hi

Try the below code

<form script="button.js">
  <init>
    <set token="hostname">*</set>
  </init>
  <label>submit button</label>
  <fieldset submitButton="false"></fieldset>
  <row depends="$hide$">
    <html>
      <style>
        .btn-search{
            color: #fff;
            padding: 6px 15px;
            font-weight: 500;
            background-color: #5cc05c;
            border: transparent;
            display: inline-block;
            height: auto;
            line-height: 20px;
            font-size: 14px;
              box-sizing: border-box;
              margin-bottom: 0;
              text-align: center;
            vertical-align: middle;
            cursor: pointer;
            border-radius: 3px;
            white-space: nowrap;
         }
         .btn-search:hover{
            background-color: #40a540;
            border-color: transparent;
            color: #fff;
            box-shadow: inset 0 -2px 0 rgba(0,0,0,.1);
            text-decoration: none;
            text-shadow: none;
            filter: none;
         }
      </style>
    </html>
  </row>
  <row>
    <panel>
      <input type="text" searchWhenChanged="false" id="host">
        <label>Filter by hostname</label>
        <default>*</default>
        <initialValue>*</initialValue>
      </input>
      <html>
         <input type="button" value="Search" id="submit_host" class="btn-search"/>
       </html>
      <table>
        <search>
          <query>index=_internal host="$hostname$" |stats count by source</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel>
      <table>
        <search>
          <query>index=_internal |stats count by sourcetype</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

javascript

require([
    "jquery", 
    "splunkjs/mvc", 
    "splunkjs/mvc/simplexml/ready!"], function($, mvc) {
        var defaultTokenModel = mvc.Components.get("submitted");
        $( "#submit_host" ).click(function() {
            var hostname= $('#host input[type="text"]').val();
            defaultTokenModel.set("hostname",hostname);
          });
    });

dmarling
Builder

This is unfortunately not supported natively in splunk. There are some work arounds that you can find on answers. Here's some suggested answers to review:

https://answers.splunk.com/answers/346916/submit-button-per-panel-in-simple-xml.html

https://answers.splunk.com/answers/683916/submit-button-inside-a-panel-is-not-working.html

If this comment/answer was helpful, please up vote it. Thank you.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...