cdklabs / cdk-monitoring-constructs

Easy-to-use CDK constructs for monitoring your AWS infrastructure
https://constructs.dev/packages/cdk-monitoring-constructs
Apache License 2.0
443 stars 56 forks source link

[lambda] Duration and/or Timeout monitoring #448

Closed haljarrett closed 5 months ago

haljarrett commented 8 months ago

Feature scope

Lambda

Describe your suggested feature

I'd like to be a able to configure monitoring of function duration to alarm if any executions are nearing the configured timeout, or timing out. Currently, I am doing this with:

myFunction.metricDuration({ statistic: 'Maximum' }).createAlarm( ... ),

but I'd like to be able to do something like:

myMonitoringFacade.monitorLambdaFunction({
  lambdaFunction: myFunctions,
  addMaxLatencyAlarm: {
    Warning: {
      maxLatencyMillis: 900_000,
    }
  }
})

The P99 latency metric is a decent proxy for this, but having an option for the maximum / P100 duration would be useful imo.

Finding and alarming on actual timeouts is a bit trickier (requires searching the logs), but is possible and would also be useful.