Hi guys, I'm trying to write a very simple external python search but it's just not working. I get the following error message in search_messages.log: 06-15-2021 09:44:22.543 +0200 ERROR SearchMessages - orig_component="script" app="search" sid="1623743052.198909" message_key="EXTERN:SCRIPT_NONZERO_RETURN" message=External search command 'pyTest' returned error code 1. Script output = "chunked 1.0,241,0\n{"inspector":{"messages":[["ERROR","RuntimeError at \"D:\\Splunk\\etc\\apps\\pyTest\\bin\\splunklib\\searchcommands\\search_command.py\", line 884 : Failed to parse transport header: b'splunkVersion:8.2.0\\n'"]]},"finished":true}". It says message_key="EXTERN:SCRIPT_NONZERO_RETURN" and "Failed to parse transport header". This is how I call the script in a splunk search: | makeresults 1 | eval something="just_a_value" | script pyTest or | script pyTest This is my commands.conf: [pyTest]
python.version = python3
chunked = true
filename = pyTest.py This is my code: #!/usr/bin/python3
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
import splunk.Intersplunk
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration
@Configuration()
class pyTest(StreamingCommand):
def stream(self, events):
for event in events:
event['nothing'] = 'world'
yield event
dispatch(pyTest, sys.argv, sys.stdin, sys.stdout, __name__) I have also tried to replace \r\n with \n in the code but that didn't help. What am I doing wrong here?
... View more