Alerting

Call CURL on Alert

rtadams89
Contributor

I would like to have Splunk send a GET request to a web page whenever an alert is triggered. I can do this from the Splunk server's CLI with

curl "http://somesite.int/page.html"

If I put that same command into the "run a script" box on the saved search page, nothing happens. Is there any way for me to call a script/executable (in this case "curl") from the Splunk saved search? If not, does anyone have an example of a script I could create in the $SPLUNK_HOME/bin/scripts/ directory and call which would allow me to pass the address ("http://somesite.int/page.html" in this example) to curl from the saved search configuration?

Tags (3)
0 Karma

Malay123
New Member

<a href="https://www.google.com">HTML</a>

0 Karma

Damien_Dallimor
Ultra Champion

You could just take the curl command , wrap it in a shell script, put that shell script in the $SPLUNK_HOME/bin/scripts directory ,chmod it to executable, and then reference this script in the "run a script box" on the alert configuration page.

There are also several parameters that Splunk passes to the script that you could potentially make use of.Refer to this link for details.

Example script :

#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  Curl Wrapper                                                            ##
### ====================================================================== ###

curl "http://somesite.int/page.html"
0 Karma

Damien_Dallimor
Ultra Champion

With current functionality , you can't pass custom arguments to the script, as alluded to in this other answer ,http://splunk-base.splunk.com/answers/25181/alerts-and-scripts-with-parameters

I have tackled a similar situation with a custom SMS alerting script I wrote, where parameters need to be passed by the triggered alert ie: the target cellphone number.

So I have 1 main alerting script that is wrapped by several other 1 liner scripts that pass the the parameter in.And users can then specify the wrapper script in the alert configuration. Not 100% ideal, but a functional workaround.

0 Karma

rtadams89
Contributor

That's a start, and I already got about that far. The problem is that I want the user who sets the alert through the GUI to be able to customize the URL that is called (not have it hard coded in the script). I'm looking for a way to not only call curl, but to pass the URL parameter to it.

0 Karma
Get Updates on the Splunk Community!

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...

[Live Demo] Watch SOC transformation in action with the reimagined Splunk Enterprise ...

Overwhelmed SOC? Splunk ES Has Your Back Tool sprawl, alert fatigue, and endless context switching are making ...

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...