ResultsReader - Unable to display results. AttributeError: itertext
I am getting following error while displaying results of a search command. Python version: 2.6.6 splunk-sdk==1.3.1
Error:
[[email protected] commands]$ ./splunksdk.py Wait for the search to finish... ...done!
Search job properties Search job ID: 1426098588.649812.splunk15.ops.expertcity.com The number of events: 1048236 The number of results: 3 Search duration: 16.927000 seconds This job expires in: 600 seconds Search results:
Traceback (most recent call last):
File "./splunksdk.py", line 44, in
Code:
!/usr/bin/python -u
import splunklib.client as client import splunklib.results as results from time import sleep import sys
service = client.connect( host=HOST, port=PORT, username=USERNAME, password=PASSWORD)
jobs = service.jobs
kwargs_blockingsearch = {"exec_mode": "blocking","earliest_time":'-1h'} searchquery_blocking = "search index=_internal source=*license_usage.log type=Usage |eval GB=b/1024/1024/1024 |eval PZGB=poolsz/1024/1024/1024| chart sum(GB) as UsageGB by pool"
print "Wait for the search to finish..."
job = jobs.create(searchquery_blocking, **kwargs_blockingsearch) print "...done!\n"
print "Search job properties" print "Search job ID: ", job["sid"] print "The number of events: ", job["eventCount"] print "The number of results:", job["resultCount"] print "Search duration: ", job["runDuration"], "seconds" print "This job expires in: ", job["ttl"], "seconds"
print "Search results:\n"
response = job.results() for result in results.ResultsReader(response): print result
Hi @amith-reddy,
We've fixed this on the develop branch, see the commit here: https://github.com/splunk/splunk-sdk-python/commit/867dd46486fa2283a9f6a4c7b750808685dba49f
Your choices at this time are:
- clone the develop branch (and potentially encounter more bugs)
- use v1.2.3 of the SDK
- use Python 2.7.x
Hopefully that helps!
I used SDK version 1.2.3 to resolve the issue. Thanks for the quick support.
Hi @amith-reddy we've just released v1.4.0 that addresses this.