Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.21k forks source link

Automatically create Lambda and ApiGateway Cloudwatch alarms (Using a config?) #1348

Open Sveder opened 6 years ago

Sveder commented 6 years ago

Lambda and ApiGateway have a lot of alarms that can be configured. For production Lambdas it is required (at least in our org) to have some basic alarms such as on Lambda timeouts, ApiGateway 4xx and 5xx and Lambda errors. Automating this using Zappa makes a lot of sense to me, although there are a lot of way to configure Cloudwatch alarms to this might add a lot of configurations to Zappa.

This should be controlled with a config that is off by default (because not every Lambda is prod and not every org cares), and specific configuration values can be set in the config with sane values that can be overridden. There are a few things that can be customized:

  1. Alarm type - Api Gateway: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/api-gateway-metrics-dimensions.html Lambda: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/lam-metricscollected.html I'd choose a subset that makes sense to be default (for example Lambda errors, timeouts, AG 4xx 5xx).

  2. Alarms threshold - per alarm (for example, our 5xx threshold is 1, we want to have an alarm for each Lambda server failure).

  3. Alarm metrics - per alarm (for example, 5xx metric is maximum).

  4. Alarm time period - per alarm (we usually set it to having the alarm over two 5 minutes periods).

Does this make sense for zappa?

scoates commented 6 years ago

I think @Miserlou has put some thought into exactly what Zappa should and shouldn't do.

I don't know if metrics and alarms fall into this at all. Would be nice to write this scope down somewhere, though, if possible.

Sveder commented 6 years ago

@scoates what do you think? Is this something you think is useful to most Zappa users?

scoates commented 6 years ago

I think it sounds useful, but I don't know if it belongs in Zappa.

Sveder commented 6 years ago

@scoates where do you think it belongs?

Anyways, I see that @Miserlou does think that it belongs, I'll try to add it in the weekend with the minimum amount of config necessary and see what he/everyone thinks.