Api Gateway does not generate metrics in CloudWatch

0

We created some API Gateway resources of type AWS::Serverless::Api with CloudFormation, where all have the same value of ApiName and with the MethodSetting parameter we enable the metrics for all paths that have the different API Gateway in the same AWS account. After creating the API Gateway resource in the Amazon console and after a few days of running requests on the API, we only see the metrics 4XXError, 5XXError, Count, Latencies and Integration Latencies corresponding to a single API Gateway, the rest of the API Gateway did not generate any metrics in CloudWatch. At this point, we decided to assign a different API name to each API Gateway. However, these API Gateways still do not generate metrics in CloudWatch. Any idea about the problem we are having?

1回答
0
承認された回答

API Gateway only enables Metrics when the 'MetricsEnabled' value is set to true for 'StageDescription' [1] on the API Gateway Stage level. If this value is diabled API Gateway will not send these metrics unless you have explicitly enabled detailed CloudWatch metrics [2] on the stage level. The 'MethodSetting' only works when the stage level metrics has been enabled, method level metrics allows you to be able to filter these metrics on cloudwatch. The 'MethodSettings' property of the Amazon API Gateway Deployment StageDescription property type contains a list of MethodSetting property types [3].

Enable stage metrics on the cloudformation stack and test if this works, eg:
StageDescription:
      Description: API details
      LoggingLevel: INFO
      MetricsEnabled: True
      MethodSettings:
        - ResourcePath: "/test"
          HttpMethod: "POST"
          LoggingLevel: INFO
          MetricsEnabled: True

References:

  1. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-deployment-stagedescription.html
  2. https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html
  3. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-deployment-methodsetting.html
AWS
回答済み 9ヶ月前
profile picture
エキスパート
レビュー済み 9ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ