Below we shall see the steps for AWS Python Lambda Monitoring using Atatus Lambda Layer(no changes in your code).

Serverless Framework

  1. Install serverless package

    npm install -g serverless
    
  2. Navigate to Atatus Dashboard --> Settings --> Account Settings --> API Keys. You can generate a new API key (select - Ingest License Key). After obtaining the API key, you'll need to set it in the serverless.yaml file under the environment ATATUS_LICENSE_KEY (see step 3).

  3. Add Lambda layers to your serverless provider configuration

    provider:
      name: aws
      runtime: python3.8
      environment:
        ATATUS_LICENSE_KEY: <YOUR_API_KEY>
      layers:
        - arn:aws:lambda:us-east-1:317265140635:layer:Atatus-Python:3
    

For Each Function:

handler: /opt/python/atatus_tracer._handler
environment:
    ATATUS_ORIGINAL_HANDLER: <YOUR_ORIGINAL_HANDLER>

4. Deploy serverless application

  sls deploy
Note:

Layers Syntax: arn:aws:lambda:<region>:317265140635:layer:Atatus-Python:<version>


SAM Template

  1. Install AWS SAM CLI

  2. Navigate to Atatus Dashboard --> Settings --> Account Settings --> API Keys. You can generate a new API key (type - Ingest License Key). After obtaining the API key, you'll need to set it in the serverless.yaml file under the environment ATATUS_LICENSE_KEY (see step 3).

  3. Add Lambda layers to your SAM provider configuration

    Globals:
      Function:
        Timeout: 600
        Layers:
          - arn:aws:lambda:us-east-1:317265140635:layer:Atatus-Python:3
        Environment:
          Variables:
            ATATUS_LICENSE_KEY: <YOUR_API_KEY>
    

For Each Function:

Handler: /opt/python/atatus_tracer._handler
Environment:
    Variables:
        ATATUS_ORIGINAL_HANDLER: <YOUR_ORIGINAL_HANDLER>

4. Build and Deploy this file along with your Lambda function.

sam build

sam deploy -g
Note:

Layers Syntax: arn:aws:lambda:<region>:317265140635:layer:Atatus-Python:<version>


AWS Console

1. Add Atatus Layer to Your Lambda Function:

  • Navigate to the AWS Management Console.
  • In the search bar at the top, type Lambda and select the Lambda service from the drop down.
  • Select the function you want to modify.
  • In the Function overview section, click on Layers.
  • Once you are in the Layers section, click on the Add a layer button.
  • Select "Specify an ARN" as Layer source and enter the following ARN
arn:aws:lambda:us-east-1:317265140635:layer:Atatus-Python:3

lambda

  • After entering the ARN, click the Add button to associate the specified layer with your Lambda function.

2. Configure Agent Environment Variables:

  • Still in your Lambda function configuration page, scroll down to the Configuration tab.
  • Within the Configuration tab, Click on Environment variables.
  • To set the agent environment variables, click the Edit button.
  • You can now set following environment variables
ATATUS_LICENSE_KEY: <YOUR_API_KEY> # Get API KEY from atatus settings

lambda

3. Update Atatus Handler in runtime settings

  • In your Lambda function configuration page, scroll down to the Code tab.
  • Within the Code tab, Click on Runtime settings.
  • To set the agent handler, click the Edit button.
  • You can now set handler as follows
/opt/python/atatus_tracer._handler

lambda

  • Click the Save button to save the changes.