Home > Software engineering >  Is it possible to set up API Gateway throttling alarm with cdk?
Is it possible to set up API Gateway throttling alarm with cdk?

Time:05-20

I have api gateway set up with cdk code. I set up different alarms for ServerError and Latency. I also would like to set up a throttling alarm. I see how to set up throttling itself but I couldn't find how to set up alarm. All other alarms I set using aws-cloudwatch lib but api gateway doesn't have metricThrottles(). What's a proper way to create throttling alarms with cdk for api gateway?

CodePudding user response:

It's a DIY job. API Gateway sends 4XX error metrics to CloudWatch, but not 429 errors alone. To isolate throttles using the CDK, you would:

  1. capture the API logs in CloudWatch
  2. create a MetricFilter to isolate the 429 events
  3. set an Alarm on that custom metric

For context beyond the CDK, see this and this SO question.

  • Related