All Apps and Add-ons

How do you print/log when creating v2 custom search command?

Path Finder


How should I approach debugging custom search commands v2 (chunked = true)?

I have followed 2017 Splunk Conf slides about custom search commands they are very great but there is no info about debugging.

How would you replace print statements in this example?

import sys
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration

class ReportingExampleCommand(ReportingCommand):
    def map(self, records):
        # print records
        return records
    def reduce(self, records):
        count = 0
        for r in records:
            # print r
            count += 1
        return [{'count': count}]

if __name__ == "__main__":
    dispatch(ReportingExampleCommand, sys.argv, sys.stdin, sys.stdout, __name__)
0 Karma