# How to plot the rate of change or the incline of a line plot?

Hi there, there is probably some statistic or mathematical concept I am missing here.

I’m plotting AWS/Billing Estimated charges in Grafana, but I am having a hard time determining if the slope if increasing or not.

Basically I want to plot the graph in such a way, that I am aware of the rates of change. I.e. if spending goes up, I can notice that increase. If spending goes down, I should be able to visualise it too.

How do I do this? There must be some calculation I can perform?

You need to use `rate` as mathematical concept here. Positive rate = slope is increasing, negative rate = slope is decreasing. Problem: that counter reset will generate high negative rate peak. Pls use CloudWatch math and RATE() function - https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html#metric-math-syntax

Thank you @jangaraj

This is what rate(metrics()) looks like for me in CloudWatch:

Yes the “counter reset will generate high negative rate peak” and I see that. But I am not really able to see anything else. Perhaps it’s being consistent with no jumps is a good thing.

Nonetheless, I am a little puzzled how to recreate the Grafana, because the AWS console falls down when you need to monitor as I do, several accounts.

Any tips for Grafana? I couldn’t grok the Expression field, is that’s what I am supposed to use.

That is OK - it calculates rate per second, so don’t expect any high numbers, but pretty small decimal numbers. For example 10k USD per month = ~0.003 USD per second. You, can still multiply result (*1000) to have better graphable values.

Ok, I agree `RATE(METRICS())*1000` in CloudWatch is better.

But I am still puzzled how to get this shown in Grafana. Is it not possible to do these calculations? I notice Prom can pull them off, but I am going direct from Grafana to CloudWatch sources.

Thanks again!

Cloudwatch math is supported https://github.com/grafana/grafana/issues/11487 I don’t see any showstopper.

Thanks for you help I think I figured it out now with your help!