Created
March 16, 2022 09:19
-
-
Save AlexanderWert/29e9b616ae6fea2833e471db61e1755b to your computer and use it in GitHub Desktop.
Elastic APM - AWS Lambda - Node.js - serverless framework example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports.hello = async (event) => { | |
return { | |
statusCode: 200, | |
body: JSON.stringify( | |
{ | |
message: 'Go Serverless v3.0! Your function executed successfully!', | |
input: event, | |
}, | |
null, | |
2 | |
), | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: my-serverless-hello-world | |
frameworkVersion: '3' | |
custom: | |
# put your Elastic APM endpoint here (e.g. the Elastic Cloud APM endpoint) | |
elasticApmServerUrl: https://XXXXXXXX.aws.cloud.es.io:443 | |
# put your secret token for your APM endpoint here | |
elasticApmSecretToken: XXXXXXXXXXX | |
elasticApmExtensionVersion: 0-0-4 | |
elasticApmNodeAgentVersion: 3-30-0 | |
elasticApmExtensionArchitecture: ${self:provider.architecture, "x86_64"} | |
provider: | |
name: aws | |
runtime: nodejs14.x | |
functions: | |
hello: | |
handler: handler.hello | |
# add these two layers to include Elastic's Node.js APM agent and Lambda extension | |
layers: | |
- arn:aws:lambda:${aws:region}:267093732750:layer:elastic-apm-node-ver-${self:custom.elasticApmNodeAgentVersion}:1 | |
- arn:aws:lambda:${aws:region}:267093732750:layer:elastic-apm-extension-ver-${self:custom.elasticApmExtensionVersion}-${self:custom.elasticApmExtensionArchitecture}:1 | |
# add the following environment variables to configure the Elastic APM extension and agent | |
environment: | |
ELASTIC_APM_LAMBDA_APM_SERVER: ${self:custom.elasticApmServerUrl} | |
ELASTIC_APM_SECRET_TOKEN: ${self:custom.elasticApmSecretToken} | |
NODE_OPTIONS: -r elastic-apm-node/start.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment