Looks like RUNNING_SUM() has been added that does what your need:
Graph with RUNNING_SUM
You can find RUNNING_SUM() under "Add math"->"All functions"
Looks like RUNNING_SUM() has been added that does what your need:
Graph with RUNNING_SUM
You can find RUNNING_SUM() under "Add math"->"All functions"
You can get a cumulative sum over the current range by using the SUM() function that is operated over the original range containing only the number One (1). Remember, you're looking for a single number in the end, so it's not much of a graph, but you need to turn the single value sum back into a time-series.
- Define
m1as your metric. This is the metric you will want to useSUM()on. - Define an expression
e1asm1/m1. This results in a time-series with every value equal to 1. This is what will allow you convert that SUM back to a time-series. - Define an expression
e2asSUM(m1) / e1. This is, effectively, the cumulative sum ofm1divided by one for every data-point in the original time-series. It will be a horizontal line on the graph, which will have every point on that horizontal line being the cumulative sum of metricm1. This is required because Cloudwatch can only plot a time-series on the chart, not a single value. - Make
m1ande1invisible. You need them, but you don't need to see them. - Finally, change the chart type from
LinetoNumber, since you only wanted the cumulative sum anyway.
The reason you can't use SUM() directly is because it is a single value. By dividing by a time-series containing all 1's, the entire graph is the result of the SUM(). Then, changing the chart to a Number effectively hides all the math and presents only the "final result".
Apparently I don't understand CloudWatch metrics, or how math works
amazon web services - AWS CloudWatch metric math with a cumulative metric's value 30 minutes ago to show rate of change - Stack Overflow
amazon web services - How does "Sum" in CloudWatch metrics and alarms work? - Stack Overflow
amazon web services - A way to get sum of continous points in cloudwatch for a sparse graph - Stack Overflow
Could someone explain this to me like I'm 5?
I'm trying to see (on a chart) how much S3 outgoing bandwidth I'm burning every month. My bill says it's been 457GB last month and 400GB the month before.
Let's say I want to set up a CloudWatch dashboard that shows me this, and I want to look at the past X months, and know how much bandwidth was consumed each month.
I set the statistic to "Sum", period to 30 days, and when I choose the past 3 months, suddenly it says I'm using 800GB over the past couple months. With the configuration I've chosen, doesn't this mean "show the past 3 months, summing up total bandwidth over 30 days"?
If I switch period to 15 minutes and mouse over the data points, it's showing about 300MB every 15 minutes. Is that 300MB of data consumption every 15 minutes? I don't see how that's possible.
(is CloudWatch Metrics maybe not the best place to do this, and I should use the Cost Explorer instead?)
You can use some arithmetic to obtain the previous value and then you're able to calculate the percentage of change as you want.
The value you want is: (value_now - value_before) / value_before
Breaking this into 2 parts:
- Obtain
value_now - value_before. This is the absolute delta of the values. - Obtain
value_before. This is the value of the metric in the last datapoint.
Assuming that your metric in Cloudwatch is m.
Step 1: The absolute delta
The absolute_delta can be obtained with: absolute_delta = RATE(m) * PERIOD(m).
Step 2: The previous value
With some arithmetic it is possible to obtain previous_value. Given the definition of absolute delta:
absolute_delta = value_now - value_before
Since we have value_now = m and absolute_delta, then it's a matter of inverting the equation:
value_before = value_now - absolute_delta
Final equation
Just plug everything together and you have your final metric:
change_percentage = 100 * absolute_delta / value_before
In CloudWatch terms:

Metric math function RATE() calculates the rate of change per second.
Returns the rate of change of the metric, per second. This is calculated as the difference between the latest data point value and the previous data point value, divided by the time difference in seconds between the two values.
From https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html
So to get the rate of change for your period you could do this:
RATE(m1)*PERIOD(m1)
and set the period of the dashboard to the wanted value.
Problem in your case is that you need it for a period of 30 min, I don't think you can set 30 min as period on the CloudWatch dashboard. Closest values would be 15 min or 1 hour.