Other Usage

Get list of reports and alerts using Splunk SDK

rajeshad
Engager

How can I use Splunk SDK/Rest API to get list of alerts and reports? For example, the page below shows total of 269 alerts. Would like to access these alerts with all its metadata (such as the underlying query).

 

Thanks!

rajeshad_0-1689373959743.png

 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Get a list of reports with this REST command

| rest /servicesNS/-/-/saved/searches splunk_server=local 
| search alert_type="always" 

Use this REST command to get a list of alerts

| rest /servicesNS/-/-/saved/searches splunk_server=local 
| search alert_type!="always"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Get a list of reports with this REST command

| rest /servicesNS/-/-/saved/searches splunk_server=local 
| search alert_type="always" 

Use this REST command to get a list of alerts

| rest /servicesNS/-/-/saved/searches splunk_server=local 
| search alert_type!="always"
---
If this reply helps you, Karma would be appreciated.
0 Karma

rajeshad
Engager

The query is not listing any events and the data is only available on Statistics tab. Is this expected or am I missing something?

rajeshad_0-1689605165357.png

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Yes, that is normal.  The rest command does not search for events - it returns information.

---
If this reply helps you, Karma would be appreciated.
0 Karma

rajeshad
Engager

Thank you, will try it out!

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...