Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up CloudWatch dimensions for APIGateway methods in CloudFormation

Tags:

I have an api say apifortest which has at 10 methods under different paths. Those methods are GET, PUT and POST. What I want to do is create a CloudWatch monitor for these.

I was looking at documentation here

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

This is what I had earlier

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]

But this alarm is being set At API Level. I want to setup at method level. The documetion does states that we can do so, but it doesn't have any example.

Any help would be appreciated.

like image 690
Em Ae Avatar asked Jun 09 '17 22:06

Em Ae


1 Answers

The documentation lists the dimensions you need to use:

  • API Name - the name of the API. You already have this.
  • Stage - the name of the stage of the API. You already have this.
  • Method - The HTTP method (e.g. GET, PUT, DELETE)
  • Resource - The resource path (e.g. /foo/bar)
like image 185
Bob Kinney Avatar answered Oct 13 '22 18:10

Bob Kinney