---
title: Update Lambda monitoring
source: https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/update-lambda-monitoring
---

After [enabling our monitoring for AWS Lambda](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/introduction-lambda/#link), you should occasionally update our Lambda function that's used to report AWS log data: `newrelic-log-ingestion`.

There are two ways to do this:

-   [Update via CLI](#update-cli): Use this if you enabled our Lambda monitoring using our [CLI tool](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/instrument-your-own/#cli).
-   [Update via AWS Serverless Application Repository](#update-sar): Use this if you enabled using the [manual procedure](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#manual-nr-lambda).

> #### ⚠️ IMPORTANT
>
> These update procedures apply to our [serverless monitoring for AWS Lambda](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/introduction-lambda), and not to our [infrastructure monitoring for AWS Lambda integration](https://docs.newrelic.com/docs/infrastructure/amazon-integrations/aws-integrations-list/aws-lambda-monitoring-integration).

## Update our Lambda integration via CLI [#update-cli]

This section describes how to update if your Lambda monitoring was enabled using our recommended [CLI tool](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#cli).

A more extensive list of [CLI commands](https://github.com/newrelic/newrelic-lambda-cli) is available on GitHub.

1.  Make sure you have the latest version of the CLI:

    ```bash
    pip install --upgrade newrelic-lambda-cli
    ```
2.  For each region in which you've installed the `newrelic-log-ingestion` function, run the following command, replacing `YOUR_REGION` with your region identifier (for example, `us-west-2`).

    ```bash
    newrelic-lambda integrations update \
        --aws-region YOUR_REGION
    ```
3.  If you do not have our logs enabled, you'll also need to update your Amazon CloudWatch log subscription filters with the following command:

    ```bash
    newrelic-lambda subscriptions install \
        --function installed \
        --aws-region YOUR_REGION
    ```

## Update layers via CLI [#update-layer-cli]

This section describes how to update your function's Layer if you installed it with our [CLI tool](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#cli).

1.  Make sure you have the latest version of the CLI:

    ```bash
    pip install --upgrade newrelic-lambda-cli
    ```
2.  Pass the `--upgrade` flag to the install command:

    ```bash
    newrelic-lambda layers install \
        --function installed \
        --nr-account-id NR_ACCOUNT_ID \
        --upgrade \
        --apm
    ```

## Update a manual Serverless application repository install [#update-sar]

If you [manually installed the ingest function from the AWS Serverless Application Repository](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#manual-nr-lambda) (and didn't use the [CLI](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#cli)), update using this procedure:

1.  Run the following, replacing `YOUR_REGION` with your region (for example, `us-west-2`).

    ```bash
    aws serverlessrepo create-cloud-formation-change-set \
       --application-id arn:aws:serverlessrepo:us-east-1:463657938898:applications/NewRelic-log-ingestion \
       --stack-name NewRelic-log-ingestion \
       --capabilities CAPABILITY_RESOURCE_POLICY CAPABILITY_IAM \
       --parameter-overrides Name=NRLicenseKey,Value=<YOUR_NR_LICENSE_KEY> \
       --region <YOUR_REGION>
    ```

    This command outputs several fields, one of which is the `ChangeSetId`: an ARN for the change set that you just created. Copy that ARN.

    If you have created the existing CloudFormation stack with the stack parameter FunctionRole, specify the function role name with `--parameter-overrides` as below.

    ```bash
    aws serverlessrepo create-cloud-formation-change-set \
       --application-id arn:aws:serverlessrepo:us-east-1:463657938898:applications/NewRelic-log-ingestion \
       --stack-name NewRelic-log-ingestion \
       --capabilities CAPABILITY_RESOURCE_POLICY CAPABILITY_IAM \
       --parameter-overrides Name=NRLicenseKey,Value=<YOUR_NR_LICENSE_KEY> Name=FunctionRole,Value=<YOUR_FUNCTION_ROLE_NAME> \
       --region <YOUR_REGION>
    ```


2.  Use the ARN in this command, which executes the change set:

    ```bash
    aws cloudformation execute-change-set --change-set-name YOUR_CHANGE_SET_ARN
    ```

## Enabling log management

If you currently don't have New Relic's log management enabled, but would like to:

1.  Make sure you have the latest version of the CLI:

    ```bash
    pip install --upgrade newrelic-lambda-cli
    ```
2.  For each region in which you've installed the `newrelic-log-ingestion` function, run the following command, replacing `YOUR_REGION` with your region (for example, `us-west-2`).

    ```bash
    newrelic-lambda integrations update \
        --enable-logs \
        --aws-region YOUR_REGION
    ```
3.  Then do either of the following:

    -   Update your Amazon CloudWatch log subscription filters for each region with the following command:

        ```bash
        newrelic-lambda subscriptions install \
            --function installed \
            --filter-pattern "" \
            --aws-region YOUR_REGION
        ```
    -   Or, you can send function logs to New Relic directly, bypassing CloudWatch and the `newrelic-log-ingestion` Lambda. To do this, set the environment variable `NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS=true` in your Lambda function configuration.

        After that, be sure to remove any existing New Relic log subscriptions for that function using this command:

        ```bash
        newrelic-lambda subscriptions uninstall \
            --function FUNCTION_NAME \
            --aws-region YOUR_REGION
        ```

        If the log subscription is present while the extension is sending logs, logs will be sent twice, resulting in duplicate log records in New Relic.

        Optionally, if you'd like to avoid [Amazon's charges](https://aws.amazon.com/cloudwatch/pricing/#Paid_tier) for CloudWatch Log ingestion, you can also modify your function's [execution role](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html) so that it doesn't grant the CloudWatch Log permissions. This will prevent your function from logging to CloudWatch.

        > #### ⚠️ CAUTION
        >
        > CloudWatch Logs ingest fees can be considerable, but this step should be taken with caution. Make sure your New Relic log ingestion integration is working well and meeting your needs before disabling CloudWatch logs.
