8

How to add CloudWatch Lambda Insights to serverless config? I don't want to do this manually, so I expect this to be an option.

I've added tracing like this:

tracing:
    lambda: true

But this only enables AWS X-ray and not the other option.

enter image description here

imacbest
  • 873
  • 1
  • 7
  • 16

2 Answers2

9

I found out that it isn't a setting but a layer in the lambda. I managed to create it with this piece of code:

provider:
  name: aws
  iamManagedPolicies:
    - "arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy"

functions:
  functionName:
    layers:
      - arn:aws:lambda:<REGION>:580247275435:layer:LambdaInsightsExtension:<VERSION>

The latest version of the lambda insights layer can be found at: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html

Jim Geurts
  • 20,189
  • 23
  • 95
  • 116
imacbest
  • 873
  • 1
  • 7
  • 16
-1

Might worth sharing that there is now a Serverless Plugin available to easily enable AWS Lambda Insights for the entire Serverless stack or individual functions.

https://www.npmjs.com/package/serverless-plugin-lambda-insights