<?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 use timechart and streamstats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295882#M89282</link>
    <description>&lt;P&gt;I don't think you want line 4 to be in there for "total" cpu time.&lt;/P&gt;

&lt;P&gt;Is there any functional advantage to using &lt;CODE&gt;_combined&lt;/CODE&gt; rather than &lt;CODE&gt;combined&lt;/CODE&gt;?  The code seems to function the same either way.  Perhaps a useful personal naming convention for working fields?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2017 14:59:05 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-03-28T14:59:05Z</dc:date>
    <item>
      <title>How to use timechart and streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295879#M89279</link>
      <description>&lt;P&gt;I have a search that will show me the top 3 processes like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=foo sourcetype=top | timechart span=1m sum(pctCPU) BY COMMAND limit=3 useother=f
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to add the total line to the top three to combine them into one total CPU line.&lt;/P&gt;

&lt;P&gt;I tried this but it did not work &lt;CODE&gt;host=foo sourcetype=top | timechart span=1m sum(pctCPU) BY COMMAND limit=3 useother=f | streamstats sum(pctCPU) as TOTAL&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any help  would be appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 14:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295879#M89279</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2017-03-28T14:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use timechart and streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295880#M89280</link>
      <description>&lt;P&gt;Like this (NOTE: You should not use &lt;CODE&gt;sum&lt;/CODE&gt; the way that you were):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=foo sourcetype=top | timechart span=1m avg(pctCPU) BY COMMAND limit=3 useother=f
| eval _combined = 0
| foreach * [ eval _combined = _combined + &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]
| eval _combined = _combined/3
| rename _combined AS combined
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 14:41:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295880#M89280</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-28T14:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use timechart and streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295881#M89281</link>
      <description>&lt;P&gt;YOu need to use foreach command for that OR addtotals &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=foo sourcetype=top | timechart span=1m sum(pctCPU) BY COMMAND limit=3 useother=f | addtotals
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=foo sourcetype=top | timechart span=1m sum(pctCPU) BY COMMAND limit=3 useother=f | eval Total=0| foreach * [eval Total=Total+'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;']
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 14:45:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295881#M89281</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-28T14:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use timechart and streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295882#M89282</link>
      <description>&lt;P&gt;I don't think you want line 4 to be in there for "total" cpu time.&lt;/P&gt;

&lt;P&gt;Is there any functional advantage to using &lt;CODE&gt;_combined&lt;/CODE&gt; rather than &lt;CODE&gt;combined&lt;/CODE&gt;?  The code seems to function the same either way.  Perhaps a useful personal naming convention for working fields?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 14:59:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295882#M89282</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-28T14:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use timechart and streamstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295883#M89283</link>
      <description>&lt;P&gt;It is as nonsensical to have a "sum of percentages" as it is to have a "total average".  I am making a guess at what he is &lt;EM&gt;really&lt;/EM&gt; needing to do, given that the metric that he is working with is an "average" of sorts ( &lt;CODE&gt;pctCPU&lt;/CODE&gt; ).  It makes NO SENSE to do &lt;CODE&gt;sum(pctCPU)&lt;/CODE&gt;; that's the point.  Therefore, my line 4 is necessary to continue working as averages (sum the 3 and divide by 3).  The trick of using &lt;CODE&gt;_combined&lt;/CODE&gt; vs. &lt;CODE&gt;combined&lt;/CODE&gt; is so that when you do &lt;CODE&gt;foreach *&lt;/CODE&gt;, the wildcard will not include the "invisible" ( &lt;CODE&gt;_*&lt;/CODE&gt; ) fields.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval a=1, b=2, c=3, _d=4, e=5
| eval _clump="clumped:" 
| foreach * [eval _clump = _clump . &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]
| rename _clump AS clump
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that the value for &lt;CODE&gt;_d&lt;/CODE&gt; is not included and notice also that &lt;CODE&gt;clumped&lt;/CODE&gt; only appears once.  Notice the "brokenness" of this, which would otherwise require extra gymnastics inside of the &lt;CODE&gt;foreach&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval a=1, b=2, c=3, _d=4, e=5
| eval clump="clumped:" 
| foreach * [eval clump = clump . &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 20:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-timechart-and-streamstats/m-p/295883#M89283</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-28T20:47:25Z</dc:date>
    </item>
  </channel>
</rss>

