Sample Node.js app for AWS Lambda demonstrating the usage of Elastic APM
APACHE-2.0 License
This is a sample Node.js application for AWS Lambda demonstrating the usage of Elastic APM.
To try the sample application you will need to install npm and Node.js. Then install the Serverless framework through npm:
npm install -g serverless
git clone https://github.com/elastic/aws-lambda-apm-sample-app.git
cd aws-lambda-apm-sample-app/lambda-application
npm install --save-dev
cd ../load-generator
npm install --save-dev
To try out Elastic APM with AWS Lambda, you will need an Elastic Stack, including an APM Server that will receive the APM data. The simplest way to get started with Elastic APM is through Elastic Cloud. Sign up for a trial on Elastic Cloud through this link.
You need to provide the corresponding connection details to the APM Server in the env.json
file. In addition, you can provide the AWS region to deploy the sample application to.
{
"aws-region": "eu-central-1",
"apm-server-url": "https://THIS_IS_YOUR_APM_SERVER_URL",
"apm-server-token": "THIS_IS_YOUR_APM_SECRET_TOKEN"
}
Make sure to use the plain APM secret token without wrapping it into an Authorization header. (e.g. a2dhFjrr84N8D24An
instead of Authorization=Bearer a2dhFjrr84N8D24An
)
To deploy to AWS you will need an AWS access key with the following permissions:
Follow the instructions for setting up AWS credentials in AWS and using them with your system.
Once your AWS credentials are set up, execute the following command in the lambda-application directory to deploy the sample application:
serverless deploy
Copy the authority part of the API Gateway's URL from the output in the console. Make sure NOT to include https://
and any path (r7ckl4adme.execute-api.eu-central-1.amazonaws.com
in the following example):
…
endpoints:
GET - https://r7ckl4adme.execute-api.eu-central-1.amazonaws.com/dev/ping
POST - https://r7ckl4adme.execute-api.eu-central-1.amazonaws.com/dev/produce
…
Change to the load-generator directory and execute the following command with the previously copied API Gateway's authority to start load generation.
sh ./load.sh <PASTE_THE_API_GATEWAY_AUTHORITY_HERE>