Dashboards & Visualizations

How to increase height of input text box html dashboard?

danosoclive
New Member

Hi, i've been banging my head against the wall for a while on this one.
I have an HTML dashboard that i would like users to be able to input details on particular issues.
These updates will generally be paragraphs of text.

As such i've been trying to give the users an expanded box in which to put their details and have so far failed.
I've tried inline height: 500px - nothing, ive tried in an external css, width works fine (so i know it the right syntax) , but no joy.

So my question is this.
Is there a way to make a text box have a multi line expanded input in html splunk?
Alternatively is there a way to use textarea and have the contents be the value of an input token?

Many thanks in advance
Dan

Labels (1)
Tags (1)
0 Karma

niketn
Legend

@danosoclive, you would need <html> textarea input for this to work which is not a default input in Splunk. However if you follow the blog by @jconger, Using HTML5 Input Types on Splunk Forms, you can have html input of your choice in your Splunk Form including Text Area. You would also need a companion Simple XML JS Extension file to capture the changes in the Text Area input and set/unset the required token accordingly.

Following is a run anywhere example to have Multiline Text Area input like Comment in Splunk.

alt text

Following is the run anywhere example Simple XML Code:

<dashboard script="html_text_area_input.js">
  <label>Multi-line Text Box Area as Splunk Input using Simple XML JS Extension</label>
  <init>
    <set token="tokComment">Not Applicable.</set>
  </init>
  <row>
    <panel>
      <html>
        <style>
          #html_ta_user_comment{
            width: 500px;
            height: 115px;            
          }
        </style>
        <div>
          <label>Enter Comment</label>
        </div>
        <div>
          <textarea id="html_ta_user_comment" name="comment" rows="10" cols="30">Not Applicable.</textarea>
        </div>
      </html>
      <table>
        <search>
          <query>| makeresults
| fields - _time
| eval "Text Entered"=$tokComment|s$</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</dashboard>

Following is the Simple XML JS Extension file html_text_area_input.js to be placed under Splunk app's appserver/static folder (may require debug refresh, bump or splunk restart along with internet browser history cleanup).

require(["jquery", 
        "splunkjs/mvc", 
        "splunkjs/mvc/simplexml/ready!"], 
    function($, mvc) {
    var defaultTokenModel = mvc.Components.get("default");
    var submitTokenModel = mvc.Components.get("submitted");
    $(document).on("change","#html_ta_user_comment",function(){
        var strComment=$(this).val();
        var strTokComment=defaultTokenModel.get("tokComment");
        if(strComment!=="" && strComment!==undefined){
            if(strTokComment!==undefined || strTokComment!==strComment){
                defaultTokenModel.set("tokComment",strComment);
                submitTokenModel.set("tokComment",strComment);
            }
        }else{
            defaultTokenModel.unset("tokComment");
            submitTokenModel.unset("tokComment");
        }
    });
});
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

klchoy
Observer

Hi, your solution worked perfectly. I have another question, how can I transfer value from another dashboard back to the "tokcomment" token?

0 Karma

DanoSOC
New Member

Hi niketnilay,

Thankyou for your comprehensive response.
However I cannot seem to get the above to work at all.
I can now define a text area and have initialised the token but it will not update the token 'on("change")' when I type something in, or at least it does not show me that it has changed. Any idea what could be going wrong?!

Thanks
Dan

0 Karma

DanoSOC
New Member

A bit of jiggery pokery later and I managed to make it work, and have successfully implemented into a HTML dashboard. Thanks for your help neketnilay !

0 Karma

emottola
Explorer

Can you be more specific about what you changed?

0 Karma

j_cabanillas
Explorer

Can you please tell me how  you made it "change "?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...