Compatibility and requirements
Logs requires an active trial or paid subscription for any New Relic product.
To use New Relic Logs with the AWS Serverless Application plugin, ensure your configuration meets the following requirements:
Enable AWS Serverless Application for New Relic Logs
To enable New Relic Logs with the AWS plugin:
- Install the New Relic Lambda
- Configure the Lambda
- Create a Lambda trigger
- Configure retries
- Generate some traffic and wait a few minutes, then check your account for data.
Install the New Relic Lambda
To install the New Relic Lambda, use the AWS Serverless Application Repository, which is where the
newrelic-log-ingestion Lambda is stored. This repo is a collection of serverless applications published by developers, companies, and partners in the serverless community. It allows developers to share their Lambda functions code with customers, who can then find and deploy the corresponding application Lambda function. Each application is packaged with an AWS Serverless Application Model (SAM) template that defines the AWS resources used.
To create the New Relic Lambda with the AWS Serverless Application Repository:
- From the AWS console, go to the Lambda section, select Create function, and select Serverless Application Repository.
- Search for
newrelicand check the box that says "Show apps that create custom IAM roles or resource policies" to find the
newrelic-log-ingestionLambda. Follow the instructions in the Lambda's documentation to deploy it. A SAM template will build the Lambda.
Configure your Lambda function
You can configure forwarding of logs to New Relic Infrastructure and/or New Relic Logging using the following environment variables:
||New Relic License key, needed for sending data to both Infrastructure and Logging. If set, enables forwarding logs to New Relic Infrastructure by default. Required.||Your New Relic license key.|
||Determines if logs are forwarded to New Relic Logging. Required.||Default:
||Determines if logs are forwarded to New Relic Infrastructure. Required.||Default:
||New Relic ingestion endpoint for Logging. Optional.||US:
||New Relic ingestion endpoint for Infrastructure. Optional.||
- Once you have updated the
function.pyand added the environment variables, click Save. Once complete, link your Lambda function to CloudWatch Logs.
Create a Lambda trigger
To get your logs streaming to New Relic you will need to attach a trigger to the Lambda:
- From the left side menu, select Functions.
- Find and select the previously created
- Under Designer, click Add Triggers, and select Cloudwatch Logs from the dropdown.
- Select the the appropriate Log group for your application.
- Enter a name for your filter.
- Optional: Enter a filter pattern.
- Check the Enable trigger checkbox, then click Add to create the trigger.
Configure retries (optional)
You can configure the number of retries you want to perform in case the function fails to send the data in case of communication issues. Recommended number is 3 retries, but you can change the retry behavior by changing the below parameters:
Please be aware that more number of retries can make the function run for longer time and therefore increases the probability of having higher costs for Lambda. On the contrary, decreasing the number of retries could increase the probability of data loss.
MAX_RETRIES = 3 # Defines the number of retries after lambda failure to deliver data INITIAL_BACKOFF = 1 # Defines the initial wait seconds until next retry is executed BACKOFF_MULTIPLIER = 2 # Time multiplier between the retries As an example, in default above configuration, first retry will happen after 1 second, second retry after 2 seconds and third retry will happen after 4 seconds.
Resources created by the SAM template
There are few resources that will be created when you create the application from the repository:
- The Lambda function itself
- A Role used to give execution permissions to the Lambda function based in CloudWatch Logs.
All other lambda configurations not listed in the steps above can be left as the defaults.
View log data
SELECT * FROM Log
Now that you've enabled Logs, here are some potential next steps:
- Explore your data using the Logs UI.
- Configure your agent to see contextual log data, such as distributed tracing, stack traces, application logs, and more.
- Query your data and create custom dashboards, charts, or alerts.
If no data appears after you enable New Relic Logs, follow the troubleshooting procedures.