<?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: custom command help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28807#M177860</link>
    <description>&lt;P&gt;Yeah Ayn...we are paid Partners for Splunk .we often get in touch with them..and they have suggested the first place to go always is splunkbase so posted this question...i want to start with my own custom commands...thanks for your link...going through it..Hopefully will be able to do some custom commands ..&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2013 14:46:15 GMT</pubDate>
    <dc:creator>rakesh_498115</dc:creator>
    <dc:date>2013-05-10T14:46:15Z</dc:date>
    <item>
      <title>custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28799#M177852</link>
      <description>&lt;P&gt;Hi ..&lt;/P&gt;

&lt;P&gt;In my Splunk results say i get a lot of numerical values for a field say "A" . Now i want avg of the top 95 values of the field A . so i have defined a funciton in python like this..&lt;/P&gt;

&lt;P&gt;// test.py&lt;/P&gt;

&lt;P&gt;def myfunction(r):&lt;BR /&gt;
   AvgBest95 = sum(r[0:95])/95&lt;/P&gt;

&lt;P&gt;return AvgBest95&lt;/P&gt;

&lt;P&gt;and i have given the command name in commands.conf&lt;/P&gt;

&lt;P&gt;[test]&lt;BR /&gt;
filename = test.py&lt;/P&gt;

&lt;P&gt;in authorize.conf also i have defined the stanga as &lt;/P&gt;

&lt;P&gt;capability::run_script_test]&lt;/P&gt;

&lt;P&gt;[role_admin]&lt;BR /&gt;
run_script_test= enabled&lt;/P&gt;

&lt;P&gt;So Now when i run the command in the search . it is not showing any values...&lt;/P&gt;

&lt;P&gt;i have used my search like this ..&lt;/P&gt;

&lt;P&gt;sourcetype="mydata" | table A | test myfunciton(A)  &lt;/P&gt;

&lt;P&gt;Please help ..if i am missing anything ...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28799#M177852</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2020-09-28T13:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28800#M177853</link>
      <description>&lt;P&gt;Is that code snippet all there is in your Python file?? In that case you have MUCH reading to do on how to create a custom command.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 08:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28800#M177853</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-09T08:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28801#M177854</link>
      <description>&lt;P&gt;yeah..the code snippnet is there in Python file...i am not getting how can i pass this value of my field A to my function in the python file....&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 10:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28801#M177854</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2013-05-09T10:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28802#M177855</link>
      <description>&lt;P&gt;You should read up on the basics before you dive into this. I honestly don't know where to start - for one, you can't call individual functions in custom commands like you're trying to do. Then there's the issue of that custom commands need to use Splunk packages for receiving and outputting data. You need to read this, among other things. &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/AdvancedDev/SearchScripts"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/AdvancedDev/SearchScripts&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 10:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28802#M177855</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-09T10:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28803#M177856</link>
      <description>&lt;P&gt;(I thought you were getting personal help from Splunk's partner team?)&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 10:57:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28803#M177856</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-09T10:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28804#M177857</link>
      <description>&lt;P&gt;If I may plug my own app, &lt;A href="http://splunk-base.splunk.com/apps/35644/base64-custom-command"&gt;http://splunk-base.splunk.com/apps/35644/base64-custom-command&lt;/A&gt;, it demonstrates just about the "most minimally viable" custom command.  There is a lot of stuff there that is absolutely necessary boilerplate.  It is boilerplate you need to understand to connect what you want your custom command "to do" to Splunk's custom command input and output plumbing.&lt;/P&gt;

&lt;P&gt;Basically, custom commands need to read events on stdin, do the needful, then write the new results to stdout.  And you will need to take into account that in certain situations your custom command may be called more than once by Splunk and may "see" the same event more than once.&lt;/P&gt;

&lt;P&gt;All of that said, why did you not simply do a &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| head 95 | stats avg(A) as avg_first_95_A
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it's not like the search language does not have these constructs built in already...&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 14:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28804#M177857</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2013-05-09T14:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28805#M177858</link>
      <description>&lt;P&gt;&lt;CODE&gt;|top A limit=95 | stats avg(A)&lt;/CODE&gt; I think is more inline with what he wants :D.  &lt;CODE&gt;&lt;A href="http://www.keepcalmandposters.com/posters/54856.png" target="test_blank"&gt;http://www.keepcalmandposters.com/posters/54856.png&lt;/A&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 14:53:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28805#M177858</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-05-09T14:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28806#M177859</link>
      <description>&lt;P&gt;Hi dwaddle,alcercogitatus ..i knew we can do the way u suggested..i wanted to get a pratice of custom commands so i have raised this question...&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2013 14:42:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28806#M177859</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2013-05-10T14:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: custom command help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28807#M177860</link>
      <description>&lt;P&gt;Yeah Ayn...we are paid Partners for Splunk .we often get in touch with them..and they have suggested the first place to go always is splunkbase so posted this question...i want to start with my own custom commands...thanks for your link...going through it..Hopefully will be able to do some custom commands ..&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2013 14:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-command-help/m-p/28807#M177860</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2013-05-10T14:46:15Z</dc:date>
    </item>
  </channel>
</rss>

