myresults,dummyresults,settings = splunk.Intersplunk.getOrganizedResults() # getting search results form Splunk
for r in myresults: # loop the results
for k, v in r.items(): # get key value pairs for each result
if k == "server": # get key
section_name = v # set value
This will check the results passed by Splunk for a field called server and if found it uses its value.
At the end of the script it will return the output back to Splunk using this line:
splunk.Intersplunk.outputResults(results) # print the result into Splunk UI