<?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: Problem with custom search command vs timechart in results chart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19764#M3042</link>
    <description>&lt;P&gt;There are some little arcane things that aren't fields but that are passed down the pipeline, but I don't think the difference is that.  I think it's a more mundane weirdness around the custom search command stuff.  Can you look at the fieldOrder in the results? A tool such as firebug can allow you to see the http traffic and you can then see the actual search results. I wonder if the fieldorder is inconsistent for some reason.  Also does the problem go away if you throw a &lt;CODE&gt;| table _time _span foo bar baz&lt;/CODE&gt; on the end of your search?&lt;/P&gt;

&lt;P&gt;UPDATE:  Indeed this was the problem and the answer was to use the optional &lt;CODE&gt;fields&lt;/CODE&gt; argument to &lt;CODE&gt;splunk.Intersplunk.outputResults()&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2013 07:01:59 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2013-04-30T07:01:59Z</dc:date>
    <item>
      <title>Problem with custom search command vs timechart in results chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19763#M3041</link>
      <description>&lt;P&gt;I've written a custom (generating) Splunk command that retrieves data from &lt;A href="http://graphite.wikidot.com/screen-shots"&gt;Carbon/Graphite&lt;/A&gt;, a numerical data-logging tool similar to RRD (but better), for the time period specified in the time-picker. The command works as I had hoped, quickly retrieving the data and providing it in columnar format, with &lt;CODE&gt;_time&lt;/CODE&gt;, &lt;CODE&gt;_span&lt;/CODE&gt;, and each requesed column of data provided as outputs. &lt;/P&gt;

&lt;P&gt;The problem is that when I click the "Results chart" button above the search results, three out of four times the chart doesn't use &lt;CODE&gt;_time&lt;/CODE&gt; as the x-axis, instead choosing one of the other columns for this, and tries to use &lt;CODE&gt;_time&lt;/CODE&gt; as the value being plotted. This problem shows up consistently for the same results over a fixed time-period (same number of points, same columns, field values, and &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;_span&lt;/CODE&gt; fields). To validate my work, I wrote another command that dumps the raw field data to a log file, and can't see anything changing in the output of my command between each execution, yet the chart handler behaves inconsistently. I also compared my results to those of &lt;CODE&gt;timechart&lt;/CODE&gt; with the same span, and they look identical in the raw data dump.&lt;/P&gt;

&lt;P&gt;Does anyone of of any magic that &lt;CODE&gt;timechart&lt;/CODE&gt; does to prepare data for the Chart module, outside of the result fields themselves?&lt;/P&gt;

&lt;P&gt;EDIT: The answer was to use the &lt;CODE&gt;fields=&lt;/CODE&gt; parameter with &lt;CODE&gt;splunk.Intersplunk.outputResults()&lt;/CODE&gt; to specify column order. I just needed to create a list of the columns, starting with &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;_span&lt;/CODE&gt;, and append the names of each generated column to the list, then provide that as the second argument:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;outputResults(results, fields=column_list)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2013 01:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19763#M3041</guid>
      <dc:creator>gcoles</dc:creator>
      <dc:date>2013-04-30T01:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom search command vs timechart in results chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19764#M3042</link>
      <description>&lt;P&gt;There are some little arcane things that aren't fields but that are passed down the pipeline, but I don't think the difference is that.  I think it's a more mundane weirdness around the custom search command stuff.  Can you look at the fieldOrder in the results? A tool such as firebug can allow you to see the http traffic and you can then see the actual search results. I wonder if the fieldorder is inconsistent for some reason.  Also does the problem go away if you throw a &lt;CODE&gt;| table _time _span foo bar baz&lt;/CODE&gt; on the end of your search?&lt;/P&gt;

&lt;P&gt;UPDATE:  Indeed this was the problem and the answer was to use the optional &lt;CODE&gt;fields&lt;/CODE&gt; argument to &lt;CODE&gt;splunk.Intersplunk.outputResults()&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2013 07:01:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19764#M3042</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-04-30T07:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom search command vs timechart in results chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19765#M3043</link>
      <description>&lt;P&gt;Thanks sideview, that definitely is the issue. The chart module only works properly when &lt;CODE&gt;_time&lt;/CODE&gt; is the first field returned. The problem is that the custom command is using the splunk API to return the results as a list of dictionaries (a dict for each row of results), and dictionaries do not allow fieldorder to be set.&lt;/P&gt;

&lt;P&gt;Do you (or anybody) know of any way to specify the fieldorder via the API as results are returned, aside from switching to csv output?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2013 17:57:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19765#M3043</guid>
      <dc:creator>gcoles</dc:creator>
      <dc:date>2013-04-30T17:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom search command vs timechart in results chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19766#M3044</link>
      <description>&lt;P&gt;Aha, I just found the optional &lt;CODE&gt;fields=&lt;/CODE&gt; parameter for &lt;CODE&gt;splunk.Intersplunk.outputResults()&lt;/CODE&gt; -- will give that a go to see if I can use it to specify column order.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;outputResults(results, messages=None, fields=None, mvdelim='\n', outputfile=&amp;lt;open file '&amp;lt;stdout&amp;gt;', mode 'w'&amp;gt;)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2013 18:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19766#M3044</guid>
      <dc:creator>gcoles</dc:creator>
      <dc:date>2013-04-30T18:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom search command vs timechart in results chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19767#M3045</link>
      <description>&lt;P&gt;(see the comments on the question for further details, because this "answer" was originally a comment up there)&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2013 19:34:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-custom-search-command-vs-timechart-in-results-chart/m-p/19767#M3045</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-04-30T19:34:54Z</dc:date>
    </item>
  </channel>
</rss>

