Skip to content

Original NewRelic Onboarding Script

Compare
Choose a tag to compare
@ewindisch ewindisch released this 20 Nov 21:16
a5c5c68

This is for the old version of this tool. See github.com/newrelic/newrelic-lambda-cli for the latest version and documentation.

Enable New Relic monitoring of AWS Lambda Cloudwatch Logs

New Relic monitoring for AWS Lambda offers in-depth performance monitoring for your Lambda functions. This document explains how to enable this feature and get started using it.

This requires you to have the AWS CLI setup and at least Python 2.6.6 installed.

Configure AWS to communicate with New Relic
In this section, you'll run a set-up script that does the following:

  • Configures your AWS account and Lambda function to communicate with New Relic.
  • Configures a New Relic log-ingestion Lambda that will send your Lambda log data to New Relic.

To use the script:

  1. Ensure you've downloaded the script and meet its requirements.
    a) Go to the newrelic-lambda-cli-master directory:
    cd newrelic-lambda-cli-master
    b) Add execution permissions to the newrelic-cloud script:
    chmod +x newrelic-cloud
  2. Optional: If you have multiple AWS profiles and don't want to use the default, use AWS_DEFAULT_PROFILEenvironment variable to set another profile name. Ensure the profile is properly configured (including the default region). Example:
export AWS_DEFAULT_PROFILE=MY_OTHER_PROFILE
  1. Run the following command in the same directory where the script is located:
./newrelic-cloud set-up-lambda-integration --nr-account-id YOUR_ACCOUNT_ID \
--linked-account-name YOUR_LINKED_ACCOUNT_NAME \
--nr-api-key YOUR_NR_API_KEY

Notes:

  • This defaults to US. If you are integrating with the New Relic EU region, add the following argument:
--nr-region "eu"
  • The value of YOUR_ACCOUNT_ID can be seen in the address bar when on the New Relic site https://rpm.newrelic.com/accounts/<YOUR_ACCOUNT_ID>
  • YOUR_LINKED_ACCOUNT_NAME is the name of your AWS account that will appear in NR Cloud integrations. It is used to easily identify your account in NR. The cloud account will be created if it does not exist yet.
  • The value of your YOUR_NR_API_KEY is your Personal API Key. This is not the same as your New Relic REST API key. To generate an API key for an existing user:
    • Ensure you are the account Owner or Admin on the account.
    • Go to rpm.newrelic.com > (account dropdown) > Account settings > Account > Users and roles.
    • Select the user.
    • Select + New API key.
    • When prompted, confirm key creation.
  • For more information about other arguments, see New Relic's Lambda documentation on GitHub .
  1. Optional: If you want to stream all logs to New Relic Logs:
    1. Go to the New Relic newrelic-log-ingestion Lambda and set the LOGGING_ENABLED environment variable to true
    2. Remove the NR_LAMBDA_MONITORING Subscription filter pattern. Go to the Log Group for each monitored Lambda, remove the newrelic-log-ingestion subscription and re-add it back. (There is no way to edit existing filter patterns).

For more manual alternatives to using the script, or to learn what actions it performs, see the manual instructions.