Skip to content

(@aws-cdk/aws-apigatewayv2): Incorrect metric names for 4xx and 5xx #14503

@kjpgit

Description

@kjpgit

My code:

  add_http_api_alarm(api: apigw.HttpApi, alarm_name: string) {
    const metric = new cloudwatch.MathExpression({
      expression: "IF(invocations > 100, (client_errors + server_errors) * 100, 0) / invocations",
      period: cdk.Duration.hours(1),
      usingMetrics: {
        client_errors: api.metricClientError({statistic:"sum"}),
        server_errors: api.metricServerError({statistic:"sum"}),
        invocations: api.metricCount({statistic: "sum"})
      }
    });

No data is being shown for metricClientError or metricServerError. That is because the CDK is incorrectly calling it 4XXError instead of 4xx required by HTTP APIs https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-metrics.html

cdk version 1.100.0 (build d996c6d)

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2bugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions