I am trying to get to the point of billing for API calls made to our services, this includes creating metrics for each API Key usage, but before I even start that I would like to understand a certain aspect of the CloudWatch logs first.
In this first image, you'll notice 1.06 million hits recorded on the graph at 6 weeks and 30 day period:
My understanding on this is that the 1.06m is the amount of hits that have taken place on this API, the "custom (6w)" is the time period, i.e. over 6 weeks of traffic and the "Period" of 30 days is the interval of the recording (i.e. split by 30 days) - this one i'm not 100% sure on.
Now, if I change the time period to longer (i.e. from 6 weeks to say, 3 months), I was expecting to see more, if not the same amount. But it's not, see the next image:
I have read through numerous AWS CloudWatch documentation, some of which, I've listed below:
- Enable or Disable Detailed Monitoring for Your Instances
- Get Statistics for a Specific Instance
- Amazon API Gateway Metrics and Dimensions
And realistically about 5 other articles (if you'd like I'll dig them out of my history for more reading).
Can anyone please shed some light on this, I'm trying to get a better understanding on a)How to read these graphs and b)Use CloudWatch for my requirement of advanced logging, mentioned above.
Thanks
You're seeing different values for datapoints because your datapoints span different time ranges in those 2 graphs.
Time range defines between which two points in time you data will be plotted. When you go to select the time range for your graph, you have 2 options:
- Absolute - You have to select specific start and end time for the graph.
- Relative - You select one of the predefined time ranges (like 1 day, 1 week, 6 week, 3 months) and Dashboards calculate the start time and end time of the graph from that.
Period is the width of each datapoint.
This applies to your graphs like this (I assume you are plotting these graphs on Aug 1st):
First graph
When you selected time range of 6 weeks, CloudWatch calculated the start time of the graph to Jun 20th and end time to Aug 1st. Because you selected period of 30 days, datapoints on the graph will cover these time ranges:
- first datapoint: Jun 20th - Jul 20th
- second datapoint: Jul 20th - Aug 1st
Second graph
When you selected time range of 3 month, CloudWatch calculated the start time of the graph to May 1st and end time to Aug 1st. Because you selected period of 30 days, datapoints on the graph will cover these time ranges:
- first datapoint: May 1st - May 31st (you don't see this one because your metric probably didn't have data for this time range)
- second datapoint: May 31st - Jun 30th
- third datapoint: Jun 30th - Jul 30th
- fourth datapoint: Jul 30th - Aug 1st
You can see what is the start time for each datapoint by hovering a mouse over the datapoint. End time is then calculated by adding the length of the period to the start time.
Now the numbers you highlighted in red mean:
- you had 1.06M hits between Jun 20th - Jul 20th
- you had 851K hits between Jun 30th - Jul 30th
Here is one example of data distribution that could create such graphs:
- Jun 20th - Jun 30th -> 200.6k hits
- Jun 30th - Jul 20th -> 800k hits
- Jul 20th - Jul 30th -> 51k hits
The first datapoint on first graph covers Jun 20th - Jul 20th, so that would show 200.6k + 800k = 1.06M
Largest datapoint on the second graph covers Jun 30th - Jul 30th, that would be 800k + 51k = 851k