Other Usage

How to use REST API for Alerts

Travis_Stanley
Observer

Hi,  I'm trying to use the REST API to get and post saved searches that are Alerts but for some reason it only returns data for Reports. Has anyone else had this problem? 

GET

Labels (1)
0 Karma

Travis_Stanley
Observer

Specifically listing them  using  the GET is proving troublesome. When I search the returned results, I don't find all alerts, but I do find all reports.

The POST to create and alert is not an issue. 

0 Karma

_JP
Contributor

This is how I have been able to access these things via REST.

The first thing you need to make sure is you have the "Add to Triggered Alerts" Alert Action that you want to be see these in the GUI or REST.  By default, Splunk will run alerts you configure, but won't necessarily "track" them unless you explicitly tell it to.  It looks like this in the GUI:

_JP_0-1697041146758.png

Once you add that Alert Action and some alerts fire, you'll see the triggered events in the GUI and via this REST endpoint:

 

/alerts/fired_alerts/

 

 

Once you're getting your list of triggered alerts, then you can find the sid value within the data returned and then use the other REST endpints to fetch stuff for the actual search that was ran.  Here's a screenshot of a bit of the output from the above rest endpoint on my test environment:

_JP_2-1697041373347.png

Also - note that the Expire setting for the alert will control how long Splunk keeps those results around for those sids:

 

_JP_3-1697041476035.png

 

 

 

0 Karma

Travis_Stanley
Observer

Hi @_JP , Thanks for the reply but that's not what I'm looking for. I want the ability to list and create alerts, not view triggered alerts.

0 Karma
Get Updates on the Splunk Community!

The OpenTelemetry Certified Associate (OTCA) Exam

What’s this OTCA exam? The Linux Foundation offers the OpenTelemetry Certified Associate (OTCA) credential to ...

From Manual to Agentic: Level Up Your SOC at Cisco Live

Welcome to the Era of the Agentic SOC   Are you tired of being a manual alert responder? The security ...

Splunk Classroom Chronicles: Training Tales and Testimonials (Episode 4)

Welcome back to Splunk Classroom Chronicles, our ongoing series where we shine a light on what really happens ...