Ability to select search modes
Currently I don't think there is an ability to select a search mode via the splunk python sdk, ie Fast, Smart, or Verbose.
We are having an issue with Splunk search time field extracting in Smart mode which breaks any query using the stats function. The splunk python sdk currently defaults to Smart mode, which means all the requests/queries we make via this module and the stats function break.
Hi @ecamarat - are you able to send adhoc_search_level as a kwarg when you create a search job?
http://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTsearch#search.2Fjobs
Using the SDK package I don't think you can. However I ended up just using the Splunk REST API directly with requests; and by doing that I could set the adhoc_search_level variable to verbose in the body of the request.
Hi, i was wondering if there was any resolution to this issue? I was having a specific issue outputting all the fields in XML (json, csv are fine). I tested this with curl and works fine, but i need this parameter in python sdk. Without this parameter adhoc_search_level = verbose, it won't populate all the fields.
Hi @ecamarata maybe it wasn't clear what was meant by using kwargs but you can definitely provide arbitrary search parameters to the service.jobs.create() method to achieve this. Here's a specific example addressing your request above using adhoc_search_level='verbose':
import time
from splunklib.client import connect
from splunklib import results
service = connect(
host='localhost',
port=8089,
username='admin',
password='changed!')
# By default the job will run in 'smart' mode which will omit events for transforming commands
job = service.jobs.create('search index=_internal | head 10 | top host')
while not job.is_ready():
time.sleep(0.5)
pass
reader = results.ResultsReader(job.events())
# Events found: 0
print(f'Events found: {len([e for e in reader])}')
# Now set the adhoc_search_level to verbose to see the events
job = service.jobs.create('search index=_internal | head 10 | top host', adhoc_search_level='verbose')
while not job.is_ready():
time.sleep(0.5)
pass
reader = results.ResultsReader(job.events())
# Events found: 10
print(f'Events found: {len([e for e in reader])}')