AWS Lambda
Monitoring for lambdas is usually difficult to set up.
With only a few lines of code, Iudex makes setting up monitoring for your lambdas super simple.
Logs
Python
If you are using Python, find your handler file and add the following code snippet before all other imports in the file:
from iudex import instrument, trace
instrument(
service_name="YOUR_SERVICE_NAME", # highly encouraged
env="prod", # dev, prod, etc
iudex_api_key="YOUR_WRITE_ONLY_API_KEY",
)
Then, find your handler function and use the trace
decorator like this:
@trace
def handler(event, context):
pass
And you’re done! Iudex automatically looks for the name of the lambda function via AWS’s environment variables and starts monitoring it.
Traces
Performance monitoring
TypeScript
If you are using JavaScript or TypeScript, find your handler file and add the following code snippet before all other imports in the file:
import { instrument, iudexAwsLambda } from 'iudex';
const { withTracing } = iudexAwsLambda;
instrument({
serviceName: <your_service_name>, // highly encouraged
env: <your_environment>, // dev, prod, etc
publicWriteOnlyIudexApiKey: <your_PUBLIC_WRITE_ONLY_key_goes_here>,
});
Then, find your handler function and wrap it using withTracing
like this:
export const handler = withTracing(
// Your handler function goes here
);
And you’re done!
API Gateway
If you use AWS API Gateway along with lambdas, replace iudexAwsLambda
with iudexAwsApiGateway
and wrap your lambda functions the same way using withTracing.
import { instrument, iudexAwsApiGateway } from 'iudex';
const { withTracing } = iudexAwsApiGateway;
instrument({
serviceName: <your_service_name>, // highly encouraged
env: <your_environment>, // dev, prod, etc
publicWriteOnlyIudexApiKey: <your_PUBLIC_WRITE_ONLY_key_goes_here>,
});
export const handler = withTracing(
// Your api gateway handler function goes here
);
And now you can monitor requests with HTTP status codes and request/response information!