Splunk Search

Deleting several saved searches in one call

strive
Influencer

Hi,

I am using Splunk REST API to delete saved searches in my java program. I would like to delete several saved searches in one call. Is it possible?

I tried something like:
DELETE saved/searches/{name,name1,name2}

and it did not work.

Thanks

Strive

Tags (1)
1 Solution

Damien_Dallimor
Ultra Champion

No , you can only delete 1 Saved Search per HTTP DELETE request to the REST endpoint

But you could easily write your own wrapper method using the Java SDK, albeit several HTTP calls will still be getting invoked in the background.

public void deleteSavedSearches(List<String>savedSearchNames){

    Map<String, Object> connectionArgs = new HashMap<String, Object>();
    connectionArgs.put("host", "mysplunkserver");
    connectionArgs.put("username", "fred");
    connectionArgs.put("password", "flintstone");

    Service splunkService = Service.connect(connectionArgs);

    SavedSearchCollection savedSearches = splunkService.getSavedSearches();

    for(String savedSearchName:savedSearchNames)
        savedSearches.remove(savedSearchName);

}

View solution in original post

0 Karma

Damien_Dallimor
Ultra Champion

No , you can only delete 1 Saved Search per HTTP DELETE request to the REST endpoint

But you could easily write your own wrapper method using the Java SDK, albeit several HTTP calls will still be getting invoked in the background.

public void deleteSavedSearches(List<String>savedSearchNames){

    Map<String, Object> connectionArgs = new HashMap<String, Object>();
    connectionArgs.put("host", "mysplunkserver");
    connectionArgs.put("username", "fred");
    connectionArgs.put("password", "flintstone");

    Service splunkService = Service.connect(connectionArgs);

    SavedSearchCollection savedSearches = splunkService.getSavedSearches();

    for(String savedSearchName:savedSearchNames)
        savedSearches.remove(savedSearchName);

}
0 Karma

strive
Influencer

After we found out that it is not possible, we implemented it like how you have mentioned. Thank you Damien.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...