API Gateway Cloudwatch高级日志记录 [英] API Gateway Cloudwatch advanced logging

本文介绍了API Gateway Cloudwatch高级日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清对我们服务进行的API调用的计费情况,这包括为每个API Key使用情况创建指标,但是在我开始之前,我想先了解CloudWatch日志的某些方面。

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.

在第一张图片中,您会注意到图表在6周30天的时间内记录了106万点击:

In this first image, you'll notice 1.06 million hits recorded on the graph at 6 weeks and 30 day period:

我的理解是,1.06m是发生的点击量在此API上,自定义(6w)是时间段,即超过6周的流量,而30天的期限是记录的间隔(即,除以30天)-这不是100%确定。

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.

现在,如果我将时间段更改为更长的时间(例如,从6周改为3个月),那么我希望能看到更多甚至更多的金额。但是不是,请看下一张图片:

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:

我已经阅读了许多AWS CloudWatch文档,其中一些如下:

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

实际上还有其他5篇文章(如果您愿意的话,可以

And realistically about 5 other articles (if you'd like I'll dig them out of my history for more reading).

任何人都可以对此有所了解,我正在尝试更好地理解a)如何阅读这些图表并b)将CloudWatch用于我上面提到的高级日志记录的需求。

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.

谢谢

推荐答案

您看到的数据点值不同,因为您的数据点在这两个图形中跨越不同的时间范围。

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:


  • 绝对-您具有来选择图表的特定开始和结束时间。

  • 相对-您可以选择一个预定义的时间范围(例如1天,1周,6周, 3个月),然后仪表板从中计算出图表的开始时间和结束时间。

  • 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.

这适用于您的图形(我假设您是在8月1日绘制这些图形):

This applies to your graphs like this (I assume you are plotting these graphs on Aug 1st):

当您选择6周的时间范围时,CloudWatch将图形的开始时间计算为 6月20日,将结束时间计算为 8月1日。由于您选择的期限为30天,因此图表上的数据点将覆盖以下时间范围:

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:


  • 第一个数据点: 6月20日至7月20th

  • 第二个数据点: 7月20日-8月1日

  • first datapoint: Jun 20th - Jul 20th
  • second datapoint: Jul 20th - Aug 1st

当您选择3个月的时间范围时,CloudWatch计算出该图的开始时间为 5月1日并结束时间到 8月1日。由于您选择了30天,因此图表上的数据点将覆盖以下时间范围:

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:


  • 第一个数据点: 5月1日-5月31st (您看不到此数据,因为您的指标可能没有该时间范围内的数据)

  • 第二个数据点: 5月31日-6月30日

  • 第三个数据点: 6月30日-7月30日

  • 第四个数据点: 7月30日-8月1st

  • 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:


  • 您在 6月20日至7月20日之间点击了106万

  • 您在 6月30日至7月30日

  • 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:


  • 6月20日-6月30日-> 20.06万点击

  • 6月30日-7月20日-> 80万点击

  • 7月20日至7月30日-> 5万次点击

第一个图表上的第一个数据点 6月20日-7月20日,因此将显示200.6k + 800k = 1.06M

The first datapoint on first graph covers Jun 20th - Jul 20th, so that would show 200.6k + 800k = 1.06M

第二张图中的最大数据点涵盖了 6月30日-7月30 ,即800k + 51k = 851k

Largest datapoint on the second graph covers Jun 30th - Jul 30th, that would be 800k + 51k = 851k

这篇关于API Gateway Cloudwatch高级日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆