<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I use reduce to avoid previewing a report from a slow search until it's done? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297892#M89854</link>
    <description>&lt;P&gt;That is the SCP V1 version of SCP V2's @Configuration(run_in_preview=False), which is already been done.&lt;/P&gt;

&lt;P&gt;The extra runs I am seeing are during preview.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:29:22 GMT</pubDate>
    <dc:creator>wegscd</dc:creator>
    <dc:date>2020-09-29T15:29:22Z</dc:date>
    <item>
      <title>How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297890#M89852</link>
      <description>&lt;P&gt;I have a ReportingCommand written in Python, and the SPL that feeds it is slowish.&lt;/P&gt;

&lt;P&gt;To minimize visual churn on the screen, I don't want my command to provide intermediate results: I just want the reduce() method to get run once when all the data is ready to process.&lt;/P&gt;

&lt;P&gt;I am using SCP 2, and I have my command annotated with run_in_preview=False, but reduce() is still getting run multiple times (with more and more input records, and preview=True is in self.metadata).&lt;/P&gt;

&lt;P&gt;The SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=whr:sap:abap:audit | stats count, values(sourcetype) as sourcetype by sid | append [ | inputlookup whirlpool_sap_instances ] | sapabapsummarize
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@Configuration(requires_preop=True, run_in_preview=False)
class SapAbapSummarizeCommand(ReportingCommand):

    @Configuration()
    def map(self, records):
        self.logger.info('SapAbapSummarizeCommand.map, phase = %s', self.phase)
        r_count = 0
        for record in records:
            r_count = r_count + 1
            yield record
        self.logger.info('SapAbapSummarizeCommand.map done: %d', r_count)

    @Configuration(run_in_preview=False)
    def reduce(self, records):
        self.logger.info('SapAbapSummarizeCommand.reduce, phase = %s', self.phase)
        self.logger.info('SapAbapSummarizeCommand.reduce, metadata = %s', self.metadata)
        r_count = 0

        for record in records:
            r_count = r_count + 1
            # (other processing)

        self.logger.info('SapAbapSummarizeCommand.reduce done: %d', r_count)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;commands.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sapabapsummarize]
filename = sap_abap_summarize.py
chunked = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get reduce to know that all the results are in? The 'Preview' flag in the metadata is always True.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:29:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297890#M89852</guid>
      <dc:creator>wegscd</dc:creator>
      <dc:date>2020-09-29T15:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297891#M89853</link>
      <description>&lt;P&gt;Put this in commands.conf&lt;/P&gt;

&lt;P&gt;[yourcommand]&lt;BR /&gt;
run_in_preview = false &lt;/P&gt;

&lt;P&gt;Which will disable preview&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:29:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297891#M89853</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2020-09-29T15:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297892#M89854</link>
      <description>&lt;P&gt;That is the SCP V1 version of SCP V2's @Configuration(run_in_preview=False), which is already been done.&lt;/P&gt;

&lt;P&gt;The extra runs I am seeing are during preview.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:29:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297892#M89854</guid>
      <dc:creator>wegscd</dc:creator>
      <dc:date>2020-09-29T15:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297893#M89855</link>
      <description>&lt;P&gt;You're clearing the configuration prior to map though... is that the cause?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:24:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297893#M89855</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-08-23T14:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297894#M89856</link>
      <description>&lt;P&gt;not sure, but I need to clear it out. If I put run_in_preview=False in map, I get &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;08-23-2017 10:29:38.001 INFO  ChunkedExternProcessor - Running process: /opt/splunk/bin/python /opt/splunk/etc/apps/wegscd_command_test/bin/sap_abap_summarize.py
08-23-2017 10:29:38.104 WARN  ChunkedExternProcessor - Unsupported metadata field sent by custom search command: run_in_preview
08-23-2017 10:29:38.104 INFO  SearchParser - PARSING: sapabapsummarize phase="map" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297894#M89856</guid>
      <dc:creator>wegscd</dc:creator>
      <dc:date>2020-09-29T15:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297895#M89857</link>
      <description>&lt;P&gt;Interesting the whole v2 is new to me.  What if you do it in commands.conf anyways?&lt;/P&gt;

&lt;P&gt;Just curious.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 15:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297895#M89857</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-08-23T15:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297896#M89858</link>
      <description>&lt;P&gt;It seems to behave using scp v1. I am putting together a test case; I'm getting very strange results.....&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 17:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297896#M89858</guid>
      <dc:creator>wegscd</dc:creator>
      <dc:date>2017-08-23T17:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use reduce to avoid previewing a report from a slow search until it's done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297897#M89859</link>
      <description>&lt;P&gt;Hi wegscd&lt;/P&gt;

&lt;P&gt;I'm having the same issue. Did you get anywhere with this? Did you managed to prevent previews somehow?&lt;/P&gt;

&lt;P&gt;j&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 15:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-reduce-to-avoid-previewing-a-report-from-a-slow/m-p/297897#M89859</guid>
      <dc:creator>jbjerke_splunk</dc:creator>
      <dc:date>2018-11-19T15:21:38Z</dc:date>
    </item>
  </channel>
</rss>

