Dashboards & Visualizations

Using HTML to execute a cURL command

jpofosho
Explorer

Hello all,

My ultimate goal is to have a button (or buttons) on a Splunk dashboard which will inform other users when they have left their desk.

my current method is to add a clickable button using HTML on a HTML converted dashboard which will execute a cURL command. The cURL command is used to send data via the HTTP Event Collector to an index which would have the latest status of each user. I am able to execute the cURL command just fine with what I have below in the CLI:

curl -k https://<HOST>:8088/services/collector -H 'Authorization: Splunk <TOKEN>' -d '{"sourcetype": "cURL", "event":"name=JOHN location=WEST status=OUT"}'

I've attempted to convert the cURL command to an HTML form for the dashboard but what I'm using doesn't pass the HEC token properly:

 <form ref='uploadForm' 
  id='uploadForm' 
 action='https://Splunk:<TOKEN>@<HOST>:8088/services/collector' 
  method='post' 
  encType="multipart/form-data">
    <input type='hidden' type="location" name="West" value="West" />
    <input type='hidden' type="name" name="John" value="John" />
    <input type='hidden' type="status" name="Out" value="Out" />
    <input type='submit' value='John is out' />
</form> 

When using the above HTML, I get the following error:

{"text":"Token is required","code":2}

Any guidance on how to pass the HEC token or a more efficient method would be greatly appreciated.

0 Karma

sanagari
New Member

Hi,
This link could be of some use to embed curl command to HTML.
https://www.embedcurl.com/

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...