<?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 to retrieve the len of the results in a custom command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235029#M69817</link>
    <description>&lt;P&gt;Hello jkat54,&lt;BR /&gt;
Thanks for your reply.&lt;BR /&gt;
Actually I have only one indexer.&lt;BR /&gt;
I found what is happening.&lt;BR /&gt;
In commands.conf there is a parameter streaming that was set to true.&lt;BR /&gt;
And in this case, Splunk split the results array in small array.&lt;/P&gt;

&lt;P&gt;I have set streaming to false and it has solved my problem. I get the good calculation.&lt;BR /&gt;
But this is still quite strange because if I log the len(results) in a file, I see that my custom command is called several times and the len(Results) that is logged is not correct. But I get the expected results ...&lt;/P&gt;

&lt;P&gt;There is an other post similar to mine :&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/29757/prevent-splunk-from-streaming-results-to-a-custom-search-command.html"&gt;https://answers.splunk.com/answers/29757/prevent-splunk-from-streaming-results-to-a-custom-search-command.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 19:24:12 GMT</pubDate>
    <dc:creator>clorne</dc:creator>
    <dc:date>2016-01-18T19:24:12Z</dc:date>
    <item>
      <title>how to retrieve the len of the results in a custom command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235026#M69814</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I am using a custom splunk command and I discovered that it has random behavior when there is more than about 4000 events.&lt;BR /&gt;
Basically my code is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#read the results into a variable
(results, dummyresults, settings) = si.getOrganizedResults()
for i in range(len(results)):
               statistics_fct(i, len)

#return the results back to Splunk
si.outputResults(results)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My issue is that &lt;STRONG&gt;len(results) is wrong:&lt;/STRONG&gt;&lt;BR /&gt;
When I call my custom command :&lt;BR /&gt;
xxxx  | head 4000  | custom_command&lt;/P&gt;

&lt;P&gt;I have 4000 event displayed as expected. &lt;BR /&gt;
But the len(results) is 3779 and I see my index 'i' moving from 0 to 3779.&lt;BR /&gt;
Then after the 3779 first events, len(results) is 221 and my index i is reseted to 0 and goes from 0 to 221.&lt;/P&gt;

&lt;P&gt;Well as a result, all my calculation is wrong because I am performing statistic with sliding window and this calculation is base on index and len(Results).&lt;/P&gt;

&lt;P&gt;Do you know how to retrieve the correct len of the "results" to be able to walk through the results.&lt;/P&gt;

&lt;P&gt;Thanks for any help&lt;BR /&gt;
Regards&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2016 23:12:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235026#M69814</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2016-01-16T23:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve the len of the results in a custom command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235027#M69815</link>
      <description>&lt;P&gt;I'm guessing you may be running into some limitation... be it RAM, or splunk limits.&lt;/P&gt;

&lt;P&gt;If you run your command and then view the job inspector, it will show you how many events were returned by each command in your pipeline.  There is also a search.log, etc.  which may give you more clues.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2016 13:36:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235027#M69815</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-01-17T13:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve the len of the results in a custom command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235028#M69816</link>
      <description>&lt;P&gt;Oh, I think I really know the answer this time.&lt;/P&gt;

&lt;P&gt;Do you have two indexers?  Are you dispatching the search to both indexers from one search head (aka distributed search)?&lt;/P&gt;

&lt;P&gt;Maybe one indexer is returning 3779 events and the other returns 221 of the events events?  The job inspector / search.log will tell you this if so.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2016 13:59:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235028#M69816</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-01-17T13:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve the len of the results in a custom command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235029#M69817</link>
      <description>&lt;P&gt;Hello jkat54,&lt;BR /&gt;
Thanks for your reply.&lt;BR /&gt;
Actually I have only one indexer.&lt;BR /&gt;
I found what is happening.&lt;BR /&gt;
In commands.conf there is a parameter streaming that was set to true.&lt;BR /&gt;
And in this case, Splunk split the results array in small array.&lt;/P&gt;

&lt;P&gt;I have set streaming to false and it has solved my problem. I get the good calculation.&lt;BR /&gt;
But this is still quite strange because if I log the len(results) in a file, I see that my custom command is called several times and the len(Results) that is logged is not correct. But I get the expected results ...&lt;/P&gt;

&lt;P&gt;There is an other post similar to mine :&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/29757/prevent-splunk-from-streaming-results-to-a-custom-search-command.html"&gt;https://answers.splunk.com/answers/29757/prevent-splunk-from-streaming-results-to-a-custom-search-command.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-retrieve-the-len-of-the-results-in-a-custom-command/m-p/235029#M69817</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2016-01-18T19:24:12Z</dc:date>
    </item>
  </channel>
</rss>

