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 July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Get More Out of Your Security Practice With a SIEM

Get More Out of Your Security Practice With a SIEMWednesday, July 31, 2024  |  11AM PT / 2PM ETREGISTER ...