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!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...