<?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 search command always shows Statistics tab in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252620#M3142</link>
    <description>&lt;P&gt;Raw event searches will show the "Events" tab, by default. &lt;BR /&gt;
Report-generating searches (stats, timechart, top, etc) will show the "Statistics" tab by default.  &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;About the search results tabs -&lt;/STRONG&gt; &lt;BR /&gt;
When you run a search, the types of search commands you use affects which&lt;BR /&gt;
search results tab get populated. If your search just retrieves events, you can&lt;BR /&gt;
view the results in the Events tab, but not in the other tabs. If the search includes&lt;BR /&gt;
transforming commands, you can view the results in the Statistics and&lt;BR /&gt;
Visualization tabs.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchTutorial/Aboutthesearchtabs"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchTutorial/Aboutthesearchtabs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;on your python script, i am not seeing any splunk commands. if you give us the splunk query, maybe, we can see, if possible to add a "raw event search command" at the end and make it return the "Events" tab by default. &lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2016 02:41:19 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2016-08-29T02:41:19Z</dc:date>
    <item>
      <title>Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252619#M3141</link>
      <description>&lt;P&gt;I have a custom search command &lt;CODE&gt;nbclosest&lt;/CODE&gt; that returns a subset of search results used like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="muni" | nbclosest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is if there were results containing log entries A, B, C, D, E, it would return a subset, say, A, B, D.&lt;/P&gt;

&lt;P&gt;It works (in that only a subset of log entries are returned), but when I run the search, the UI always shows the &lt;STRONG&gt;Statistics&lt;/STRONG&gt; tab containing &lt;EM&gt;every&lt;/EM&gt; field in column format ( &lt;CODE&gt;_raw&lt;/CODE&gt;, &lt;CODE&gt;_time&lt;/CODE&gt;, ... &lt;CODE&gt;date_wday&lt;/CODE&gt;, ...).&lt;/P&gt;

&lt;P&gt;I want it to show the &lt;STRONG&gt;Events&lt;/STRONG&gt; tab as usual, but only the returned subset. (The &lt;STRONG&gt;Events&lt;/STRONG&gt; tab shows all the original pre-filtered log entries.)&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1775iD27A1DD4CDB6AA3E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I get what I want?&lt;/P&gt;

&lt;P&gt;FYI, my &lt;CODE&gt;commands.conf&lt;/CODE&gt; is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[nbclosest]
filename = nbclosest.py
enableheader = false
overrides_timeorder = true
required_fields = _time,vehicle_id,vehicle_distance,stop_tag
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The script is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#! /usr/bin/env python

import csv
import operator
import sys

K_STAG      = 'stop_tag'
K_TIME      = '_time'
K_VDISTANCE = 'vehicle_distance'
K_VID       = 'vehicle_id'

vehicle_dict = { }

try:
    reader = csv.DictReader( sys.stdin )
    headers = reader.fieldnames
    writer = csv.DictWriter( sys.stdout, headers )
    writer.writeheader()

    for row in reader:
        vid = row[ K_VID ]
        if vid not in vehicle_dict:
            vehicle_dict[ vid ] = row
        else:
            old_row = vehicle_dict[ vid ]
            old_stop = old_row[ K_STAG ]
            new_stop =     row[ K_STAG ]
            if new_stop == old_stop:
                old_distance = int( old_row[ K_VDISTANCE ] )
                new_distance = int(     row[ K_VDISTANCE ] )
                if new_distance &amp;lt;= old_distance:
                    vehicle_dict[ vid ] = row
            else:
                writer.writerow( old_row )
                vehicle_dict[ vid ] = row

    remaining_rows = vehicle_dict.values()
    for row in sorted( remaining_rows, key=operator.itemgetter( K_TIME ) ):
        writer.writerow( row )

except Exception as e:
    import traceback
    stack = traceback.format_exc()
    print &amp;gt;&amp;gt;sys.stderr, "Unhandled exception: %s; %s" % (e, stack)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Aug 2016 01:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252619#M3141</guid>
      <dc:creator>plucas_splunk</dc:creator>
      <dc:date>2016-08-28T01:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252620#M3142</link>
      <description>&lt;P&gt;Raw event searches will show the "Events" tab, by default. &lt;BR /&gt;
Report-generating searches (stats, timechart, top, etc) will show the "Statistics" tab by default.  &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;About the search results tabs -&lt;/STRONG&gt; &lt;BR /&gt;
When you run a search, the types of search commands you use affects which&lt;BR /&gt;
search results tab get populated. If your search just retrieves events, you can&lt;BR /&gt;
view the results in the Events tab, but not in the other tabs. If the search includes&lt;BR /&gt;
transforming commands, you can view the results in the Statistics and&lt;BR /&gt;
Visualization tabs.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchTutorial/Aboutthesearchtabs"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchTutorial/Aboutthesearchtabs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;on your python script, i am not seeing any splunk commands. if you give us the splunk query, maybe, we can see, if possible to add a "raw event search command" at the end and make it return the "Events" tab by default. &lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 02:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252620#M3142</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-08-29T02:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252621#M3143</link>
      <description>&lt;P&gt;Actually, I finally figured out how to use the protocol version 2 (the documentation is pretty sketchy). My scripts using v2 works as I want. So I suppose never mind.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 14:13:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252621#M3143</guid>
      <dc:creator>plucas_splunk</dc:creator>
      <dc:date>2016-08-29T14:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252622#M3144</link>
      <description>&lt;P&gt;How can you do that please?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 19:57:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252622#M3144</guid>
      <dc:creator>irsysintegratio</dc:creator>
      <dc:date>2017-09-11T19:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252623#M3145</link>
      <description>&lt;P&gt;Actually it does not need v2. V1 works as well. Just need to set this in your command.conf for the command:&lt;BR /&gt;
retainsevents=true&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 20:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252623#M3145</guid>
      <dc:creator>irsysintegratio</dc:creator>
      <dc:date>2017-09-11T20:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command always shows Statistics tab</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252624#M3146</link>
      <description>&lt;P&gt;But new code should use v2.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 20:38:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-always-shows-Statistics-tab/m-p/252624#M3146</guid>
      <dc:creator>plucas_splunk</dc:creator>
      <dc:date>2017-09-11T20:38:21Z</dc:date>
    </item>
  </channel>
</rss>

