Epsagon
Using Epsagon with Stackery
Epsagon increases the observability of serverless stacks, giving you health information and deep tracing of poorly performing AWS Lambda functions. Epsagon also builds a useful cost estimation dashboard.
To add the Epsagon SDK to your stack, all you need to do is add it to your function's package.json
requirements. Start by pulling your Stackery stack down to your local machine. Below your stack name you'll find the link to your code repository:
More detailed instructions on working with your code repository can be found in our Quickstart guide.
In your local shell or terminal, navigate to src/[function name]
within your repository. Then install the SDK with:
npm config set '//registry.npmjs.org/:_authToken' '3325bbb0-195f-4c59-abeb-edf8a0755be7' && npm install @epsagon/epsagon
Now you can modify your basic Lambda code to include the Epsagon SDK and wrap your function:
const fs = require('fs');
const epsagon = require('@epsagon/epsagon');
epsagon.init({
token: '<your-token>', //find this in your Epsagon account settings
appName: '<choose-your-app-name>',
metadataOnly: false,
});
exports.handler = epsagon.lambdaWrapper(async event => {
// Log http request
console.log(event);
const responseBody = fs.readFileSync('./welcome.html', 'utf8');
// Build an HTTP response.
const response = {
statusCode: 200,
headers: {
'Content-Type': 'text/html'
},
body: responseBody
};
return response;
});
Next, commit your code up to your repository with git add . && git commit -m "added Epsagon" && git push
.
With that, it's time to go back to the Stackery dashboard and deploy this stack!
Stackery will note that you've updated your repo and prompt you to refresh the stack (nothing visual will change since we're only changing the code underlying one function).
After hitting Prepare Deployment and Deploy you'll be taken to the CloudFormation Console, where you can execute these changes. If your function is activated frequently you'll see data within about 20 minutes!
Now that the initial version is set up, you can gather a lot more information by adding Epsagon's custom stack to your CloudFormation dashboard.
