<?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 Selecting which fields to plot based on subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Selecting-which-fields-to-plot-based-on-subsearch/m-p/143096#M39733</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am trying to create a timechart which data would be based on a subsearch. Here is what I have so far : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perf_mon test_nvidia |  | timechart bins=100 [search  | rex mode=sed field=gpus "s/GPU(\d+)/avg(mem_used\1_GB) as GPU\1,/g" | nomv gpus | rename gpus as search| format "" "" "" "" "" "by host" | rex mode=sed field=search "s/\"//g"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first search yields fields named&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mem_used0_GB
...
mem_used7_GB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, the subsearch &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=gpus "s/GPU(\d+)/avg(mem_used\1_GB) as GPU\1,/g" | nomv gpus | rename gpus as search| format "" "" "" "" "" "by host" | rex mode=sed field=search "s/\"//g"
produces a single field called "search", which contains : 
 avg(mem_used4_GB) as GPU4, avg(mem_used5_GB) as GPU5, by host 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, when I add the subsearch to the timechart command, Splunk gives me the error : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'timechart' command: The argument ' avg(mem_used5_GB)' is invalid. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong ?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Dec 2014 14:49:28 GMT</pubDate>
    <dc:creator>mboisson</dc:creator>
    <dc:date>2014-12-04T14:49:28Z</dc:date>
    <item>
      <title>Selecting which fields to plot based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Selecting-which-fields-to-plot-based-on-subsearch/m-p/143096#M39733</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am trying to create a timechart which data would be based on a subsearch. Here is what I have so far : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perf_mon test_nvidia |  | timechart bins=100 [search  | rex mode=sed field=gpus "s/GPU(\d+)/avg(mem_used\1_GB) as GPU\1,/g" | nomv gpus | rename gpus as search| format "" "" "" "" "" "by host" | rex mode=sed field=search "s/\"//g"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first search yields fields named&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mem_used0_GB
...
mem_used7_GB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, the subsearch &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=gpus "s/GPU(\d+)/avg(mem_used\1_GB) as GPU\1,/g" | nomv gpus | rename gpus as search| format "" "" "" "" "" "by host" | rex mode=sed field=search "s/\"//g"
produces a single field called "search", which contains : 
 avg(mem_used4_GB) as GPU4, avg(mem_used5_GB) as GPU5, by host 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, when I add the subsearch to the timechart command, Splunk gives me the error : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'timechart' command: The argument ' avg(mem_used5_GB)' is invalid. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong ?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2014 14:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Selecting-which-fields-to-plot-based-on-subsearch/m-p/143096#M39733</guid>
      <dc:creator>mboisson</dc:creator>
      <dc:date>2014-12-04T14:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting which fields to plot based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Selecting-which-fields-to-plot-based-on-subsearch/m-p/143097#M39734</link>
      <description>&lt;P&gt;I have not managed to do it within the timechart command. However, it works if I first do it in a "fields" command, aka : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perf_mon test_nvidia | fields [search ... ],_*,host | timechart ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Dec 2014 15:51:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Selecting-which-fields-to-plot-based-on-subsearch/m-p/143097#M39734</guid>
      <dc:creator>mboisson</dc:creator>
      <dc:date>2014-12-04T15:51:11Z</dc:date>
    </item>
  </channel>
</rss>

