<?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 How do you chart a cumulative sum? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76713#M19405</link>
    <description>&lt;P&gt;I'm calculating the sum of spending over a month period.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | timechart sum(value) span=1mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will produce the cumalative amount, but it won't show you how you arrived at the amount in day incements. Changing the span to 1 day, doesn't produce the desired result nor does bucketing ahead of the timechart.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; * | timechart sum(value) span=1mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do you achieve this without some major delta hack?&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jun 2012 14:45:56 GMT</pubDate>
    <dc:creator>Marinus</dc:creator>
    <dc:date>2012-06-15T14:45:56Z</dc:date>
    <item>
      <title>How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76713#M19405</link>
      <description>&lt;P&gt;I'm calculating the sum of spending over a month period.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | timechart sum(value) span=1mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will produce the cumalative amount, but it won't show you how you arrived at the amount in day incements. Changing the span to 1 day, doesn't produce the desired result nor does bucketing ahead of the timechart.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; * | timechart sum(value) span=1mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do you achieve this without some major delta hack?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 14:45:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76713#M19405</guid>
      <dc:creator>Marinus</dc:creator>
      <dc:date>2012-06-15T14:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76714#M19406</link>
      <description>&lt;P&gt;You could use &lt;CODE&gt;accum&lt;/CODE&gt; to create the cumulative sum and then do a &lt;CODE&gt;timechart last()&lt;/CODE&gt; on this sum to get the last value at the breakpoint of each interval and finally arriving at the total sum:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | accum value as totalvalue | timechart last(value) span=1d
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Jun 2012 14:57:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76714#M19406</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-06-15T14:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76715#M19407</link>
      <description>&lt;P&gt;Ironically it produces the opposite result. It's stepping down from the cumulative total. &lt;BR /&gt;
| accum value as totalvalue | timechart last(totalvalue) span=1d&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 18:01:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76715#M19407</guid>
      <dc:creator>Marinus</dc:creator>
      <dc:date>2012-06-15T18:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76716#M19408</link>
      <description>&lt;P&gt;The answer is not pretty but it works, thanks Ayn.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;enter code here&lt;/CODE&gt;| reverse | accum value as totalvalue | timechart last(totalvalue) span=1d&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 18:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76716#M19408</guid>
      <dc:creator>Marinus</dc:creator>
      <dc:date>2012-06-15T18:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76717#M19409</link>
      <description>&lt;P&gt;you want to use the &lt;CODE&gt;streamstats&lt;/CODE&gt; command. &lt;/P&gt;

&lt;P&gt;1) simple example,  running the timechart first and using streamstats to create the cumulative total on the timechart output rows.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;* | timechart count| streamstats sum(count) as cumulative&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;2) similar,  but with a field value instead of the count: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal source=*metrics.log group=per_sourcetype_thruput | timechart sum(kb) as totalKB | streamstats sum(totalKB) as totalCumulativeKB&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;3) If you want to go the other way, and use &lt;CODE&gt;streamstats&lt;/CODE&gt; on the raw events, you can do that, but then you have to use the &lt;CODE&gt;reverse&lt;/CODE&gt; command. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal source=*metrics.log group=per_sourcetype_thruput | reverse |  streamstats sum(kb) as cumulativeKB | timechart max(cumulativeKB)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;4) And streamstats also allows a 'by' term, so for example it can keep track of all of these cumulative numbers separately by some field value like 'series': &lt;/P&gt;

&lt;P&gt;With the streamstats before the reporting command: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal source=*metrics.log group=per_sourcetype_thruput | reverse |  streamstats sum(kb) as cumulativeKB by series | timechart max(cumulativeKB) by series&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and last but not leasat, if you want to use the other way and use streamstats after the reporting command, you have to get a little more hands-on with stats and bin.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal source=*metrics.log group=per_sourcetype_thruput | bin _time span=1h | streamstats sum(kb) as totalKB by _time series | timechart sum(totalKB) by series&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 19:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76717#M19409</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-06-15T19:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76718#M19410</link>
      <description>&lt;P&gt;This will be a lot more efficient if you do a stats table first, statsing by _time and the value you're interested in. Plus, you won't need a reverse anymore, because the stats table will be ordered by time: &lt;CODE&gt;search ... | bucket _time span=1d | stats sum(value) as value | accum value as totalvalue | timechart last(totalvalue) span=1d&lt;/CODE&gt; - use the same bucketing of _time as the span in timechart and splunk has even less work to do in the timechart.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:26:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76718#M19410</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2013-12-11T20:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76719#M19411</link>
      <description>&lt;P&gt;I found this to work well: statsing by _time and your split-by field. It is more efficient as you are not potentially reversing hundreds of thousands of events: &lt;CODE&gt;index=_internal source=*license_usage.log type=Usage | eval MB=b/1024/1024 | bucket _time span=1h | stats sum(MB) as MB by st | streamstats sum(MB) as MB by st | timechart span=1h last(MB) as MB by st&lt;/CODE&gt; is a nice cumulative graph of indexing today by sourcetype. And over a day it creates 25 rows, which is a lot easier to reverse than 800,000 original log lines...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76719#M19411</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2020-09-28T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76720#M19412</link>
      <description>&lt;P&gt;I used the same function but but it is accumulating all the sum of 3 status where i want to accumulate the sum by status. Any idea how can i do that ?&lt;BR /&gt;
| accum value as totalvalue | timechart last(totalvalue) by STATUS&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 08:07:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/76720#M19412</guid>
      <dc:creator>royimad</dc:creator>
      <dc:date>2014-11-19T08:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do you chart a cumulative sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/621747#M216128</link>
      <description>&lt;P&gt;I too had the problem and I sorted using a simple trick.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of timechart or chart use stats. for the time value, you can use time extract command&lt;/P&gt;&lt;P&gt;Note - Remember to select&amp;nbsp;CumulativeTotal as chart overlay to better show the graph in your search panel.&lt;BR /&gt;&lt;BR /&gt;Here is how you can achieve -&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;index=&amp;lt;indexname&amp;gt; sourcetype=&amp;lt;sourcetypename&amp;gt; &amp;lt;&amp;lt;search string&amp;gt;&amp;gt;&lt;BR /&gt;| eval HourMinute=strftime(_time, "%m/%d %H%p")&lt;BR /&gt;| stats count(_raw) as count by HourMinute |&lt;/P&gt;&lt;P&gt;appendcols [searchindex=&amp;lt;indexname&amp;gt; sourcetype=&amp;lt;sourcetypename&amp;gt; &amp;lt;&amp;lt;search string&amp;gt;&amp;gt;&lt;BR /&gt;| eval HourMinute=strftime(_time, "%m/%d %H%p")&lt;BR /&gt;| stats count(_raw) as count by HourMinute |streamstats sum(count) as CumulativeTotal ]&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 19:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-chart-a-cumulative-sum/m-p/621747#M216128</guid>
      <dc:creator>ManasNayak</dc:creator>
      <dc:date>2022-11-22T19:21:57Z</dc:date>
    </item>
  </channel>
</rss>

