Alarm for AWS API Gateway


How can i set alarms for AWS API gateway using serverless? I want to set alarms whenever a request is returned 4xx/5xx responses by my API.
I found a plugin to add alerts for lambda functions, but not for AWS api gateway.

Adding alert to Lambda is not preferred because:

  1. Some calls may not reach Lambda functions (for example if request fails to authenticate).
  2. One API Gateway endpoint may invoke multiple lambda functions. I don’t want to create multiple alerts


You would create a cloudwatch alarm resource separately and target the cloudwatch metrics from your api gateway using the Ref object for the gateway id in the alarm. In cloudwatch there are metrics for all resources. Just target the ones u want using cloudformation and an alarm.