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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...