<?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 Custom search command error: Failed to write buffer of size 21 to external process file descriptor in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-error-Failed-to-write-buffer-of-size-21-to/m-p/531333#M9538</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm writing a custom search command, and I'm running into the following error:&lt;/P&gt;&lt;PRE&gt;Failed to write buffer of size 21 to external process file descriptor (Broken pipe)&lt;/PRE&gt;&lt;P&gt;The custom search is an eventing command (command name is 'sum'):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/usr/bin/python
import exec_anaconda
exec_anaconda.exec_anaconda()
import pandas as pd
import os,sys
import logging, logging.handlers
import splunk

from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option, validators


@Configuration()
class ExEventsCommand(EventingCommand):
    def transform(self, records):
        l = list(records)
        l.sort(key=lambda r: r['_raw'])
        
        return l

if __name__ == "__main__":
    dispatch(ExEventsCommand, sys.argv, sys.stdin, sys.stdout, __name__)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error occurs only sometimes - it looks like it is dependent on the amount of data that is returned by the search.&lt;/P&gt;&lt;P&gt;This is illustrated by the following searches:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = _internal | head 10000 | sum (no error)
index = _internal | head 100000 | sum (error)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Nov 2020 14:20:26 GMT</pubDate>
    <dc:creator>BernardEAI</dc:creator>
    <dc:date>2020-11-30T14:20:26Z</dc:date>
    <item>
      <title>Custom search command error: Failed to write buffer of size 21 to external process file descriptor</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-error-Failed-to-write-buffer-of-size-21-to/m-p/531333#M9538</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm writing a custom search command, and I'm running into the following error:&lt;/P&gt;&lt;PRE&gt;Failed to write buffer of size 21 to external process file descriptor (Broken pipe)&lt;/PRE&gt;&lt;P&gt;The custom search is an eventing command (command name is 'sum'):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/usr/bin/python
import exec_anaconda
exec_anaconda.exec_anaconda()
import pandas as pd
import os,sys
import logging, logging.handlers
import splunk

from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option, validators


@Configuration()
class ExEventsCommand(EventingCommand):
    def transform(self, records):
        l = list(records)
        l.sort(key=lambda r: r['_raw'])
        
        return l

if __name__ == "__main__":
    dispatch(ExEventsCommand, sys.argv, sys.stdin, sys.stdout, __name__)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error occurs only sometimes - it looks like it is dependent on the amount of data that is returned by the search.&lt;/P&gt;&lt;P&gt;This is illustrated by the following searches:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = _internal | head 10000 | sum (no error)
index = _internal | head 100000 | sum (error)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 14:20:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-error-Failed-to-write-buffer-of-size-21-to/m-p/531333#M9538</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2020-11-30T14:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command error: Failed to write buffer of size 21 to external process file descriptor</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-error-Failed-to-write-buffer-of-size-21-to/m-p/532404#M9539</link>
      <description>&lt;P&gt;In commands.conf, the default number of events that can be passed to a custom search command per invocation is determined by `maxinputs` and defaults to 50,000 - see here:&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.0/Admin/Commandsconf#.5B.26lt.3BSTANZA_NAME.26gt.3B.5D" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.1.0/Admin/Commandsconf#.5B.26lt.3BSTANZA_NAME.26gt.3B.5D&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If your custom search command is expected to have input higher than that, you might investigate relaxing that constraint.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 21:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-error-Failed-to-write-buffer-of-size-21-to/m-p/532404#M9539</guid>
      <dc:creator>thellmann</dc:creator>
      <dc:date>2020-12-08T21:52:45Z</dc:date>
    </item>
  </channel>
</rss>

