I worked on splunk sdk and got the events for the given search query but I want to display only Priority with their corresponding count value in the console... someone help me in how to do that???
output screenshot has attached.][1]
Here is my python script to print this output:
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
for app in service.apps:
print (app.name)
kwargs_export = {"search_mode": "normal"}
searchquery_export = "search sourcetype=db| stats count by Priority"
exportsearch_results = service.jobs.export(searchquery_export, **kwargs_export)
# Get the results and display them using the ResultsReader
print (exportsearch_results.read())
What is the reason you're using python for this? Maybe you're trying to learn with an extremely simple example of a python script, but in such a simple case you should simply run it in the console with splunk itself.
You can read more about how to use Splunk to run searches on the command line here - http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/CLIsearchsyntax