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!

Splunk Smartness with Brandon Sternfield | Episode 3

Hello and welcome to another episode of "Splunk Smartness," the interview series where we explore the power of ...

Monitoring Postgres with OpenTelemetry

Behind every business-critical application, you’ll find databases. These behind-the-scenes stores power ...

Mastering Synthetic Browser Testing: Pro Tips to Keep Your Web App Running Smoothly

To start, if you're new to synthetic monitoring, I recommend exploring this synthetic monitoring overview. In ...