在 CloudFormation 中为 APIGateway 方法设置 CloudWatch 维度

Em *_* Ae 5 amazon-web-services aws-cloudformation amazon-cloudwatch aws-api-gateway

我有一个 api 说apifortest,它在不同的路径下有 10 种方法。这些方法是GET,PUTPOST。我想要做的是为这些创建一个 CloudWatch 监视器。

我在这里查看文档

http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/api-gateway-metrics-dimensions.html

这是我之前的

TestApiCloudWatch:
    Type: "AWS::CloudWatch::Alarm"
    Properties:
        ActionsEnabled: "True"
        AlarmName: "ApiGateway-TestAPI-5XXError-SEV2"
        ComparisonOperator: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, ComparisonOperator]
        Dimensions:
            -
                Name: "ApiName"
                Value: "APIForTest"
            -
                Name: "Stage"
                Value: "Prod"
        EvaluationPeriods: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, EvaluationPeriods]
        MetricName: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, MetricName]
        Namespace: "AWS/ApiGateway"
        Period: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, Period]
        Statistic: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, Statistic]
        Threshold: !FindInMap [APIGatewayCloudWatchMappings, 5XXError-SEV2, Threshold]
Run Code Online (Sandbox Code Playgroud)

但是这个警报是在 API 级别设置的。我想在方法级别进行设置。文档确实说明我们可以这样做,但它没有任何示例。

任何帮助,将不胜感激。

Bob*_*ney 4

该文档列出了您需要使用的尺寸:

  • API 名称 - API 的名称。你已经有了这个。
  • 阶段 - API 阶段的名称。你已经有了这个。
  • 方法 - HTTP 方法(例如 GET、PUT、DELETE)
  • 资源 - 资源路径(例如/foo/bar)