All Apps and Add-ons

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

seva98
Path Finder

Hi,

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

@Configuration()
class ReportingExampleCommand(ReportingCommand):
    @Configuration()
    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
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...