Splunk Enterprise

Splunk API can not find all savedsearches

Na_Kang_Lim
Path Finder

I am creating a python script using Splunk SDK for Python to automate one of my tasks - update all savedsearches to run as 'fast' mode (instead of 'verbose' and 'smart')

This is where I'm at:

query = '| rest /servicesNS/-/-/saved/searches | where disabled=0 | search "display.page.search.mode"!="fast" "eai:acl.app"!="splunk_archiver" "eai:acl.app"!="splunk_monitoring_console" "eai:acl.app"!="splunk_instrumentation" "eai:acl.owner"!="nobody" | table title cron_schedule eai:acl.owner actions eai:acl.app action.email.message.alert action.email.to action.email.cc search updated description display.page.search.mode'

service = client.connect(
    host='<my_splunk_search_head_url>',
    port=443,
    scheme='https',
    verify=False,
    autologin=True,
    token=token,
)

job = service.search(query=query, output_mode='json')
total_elapsed_time = 0

while not job.is_done():
    sleep(.2)
    total_elapsed_time += 0.2

print(f"Job is {job.is_done()} after {total_elapsed_time} secs")

list_rule_not_running_fast_mode = []

rr = results.JSONResultsReader(job.results(output_mode='json'))
for result in rr:
    if isinstance(result, results.Message):
        print(f'{result.type}: {result.message}')
    elif isinstance(result, dict):
        print(result['title'])
        list_rule_not_running_fast_mode.append(result['title'])

all_saved_searchs = service.saved_searches

The query could return all the savedsearches not running in 'fast' mode, however, the service.saved_searches list could not find all the returned savedsearch names.

So in short, the problem is, service.saved_searches does not contain all of my savedsearches.

What am I missing here?

Tags (2)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @Na_Kang_Lim 

If you add count=0 after your URL in the rest command does it return more results?

| rest /servicesNS/-/-/saved/searches count=0

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

PickleRick
SplunkTrust
SplunkTrust

I don't have much experience with Splunk SDK but the first thing that comes to mind is pagination. AFAIR by default search results fetch 1000 rows or something like that and you have to explicitly read more (but I have no idea if SDK works around it automatically).

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...