diff --git a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/configure-serverless-monitoring-aws-lambda.mdx b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/configure-serverless-monitoring-aws-lambda.mdx index 94cfb73b73d..93f1f54ce40 100644 --- a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/configure-serverless-monitoring-aws-lambda.mdx +++ b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/configure-serverless-monitoring-aws-lambda.mdx @@ -27,3 +27,371 @@ Our let you get notifications on anything you ca Besides the data we provide by default, you can also set up your own [events](/docs/using-new-relic/welcome-new-relic/get-started/glossary#event) or [attributes](/docs/using-new-relic/welcome-new-relic/get-started/glossary#attribute). For details about these language-specific settings, see [Configuring custom attributes and events in AWS Lambda](https://discuss.newrelic.com/t/configuring-custom-attributes-and-events-in-aws-lambda/96043). + +## Environment variables [#environment] + +It's important to configure your Lambda functions with the New Relic environment variables that match your monitoring needs. Choose your runtime to see the available environment variables and our recommendations for default settings. + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED``false``true`, `false`Enable or disable distributed tracing
`NEW_RELIC_PRIMARY_APPLICATION_ID`Your New Relic account ID
`NEW_RELIC_DEBUG``false``true`, `false`Agent log level
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED``false``true`, `false`Enable or disable distributed tracing (Java excluded)
`NEW_RELIC_NO_CONFIG_FILE``false``true`, `false`The Node.js agent uses environment variables in Lambda, so this should be set to `true`
`NEW_RELIC_APP_NAME`Should be set but is not used in the New Relic UI. Instead, entity names come from the AWS integration.
`NEW_RELIC_LOG_ENABLED``false``true`,`false`Outputs agent logs to CloudWatch
`NEW_RELIC_LOG_LEVEL``info``fatal`, `error`, `warn`, `info`, `debug`, `trace`Agent log level
`NEW_RELIC_LOG``stdout``stdout`Agent log path should be stdout for the Node.js agent in serverless mode
`NEW_RELIC_USE_ESM``false``true`, `false`ESM functions that use async/await and not callbacks
`NEW_RELIC_NATIVE_METRICS_ENABLED``true``true`, `false`Should be set to false to reduce cold start duration. When set to `false` it does not collect VM metrics
+ +You can find more environment variables in our [Node.js configuration documentation](/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/). + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED``false``true`, `false`Enable or disable distributed tracing (Java excluded)
`NEW_RELIC_NO_CONFIG_FILE``false``true`, `false`Agent uses environment variables in Lambda so this should be set to true
`NEW_RELIC_APP_NAME`Should be set but is not used in the New Relic UI. Instead, entity names come from the AWS integration.
`NEW_RELIC_LOG``stderr``stderr`Agent log path should be `stderr `for the Python agent in serverless mode
`NEW_RELIC_LOG_LEVEL``info``critical`, `error`, `warning`, `info`, `debug`Agent log level
`NEW_RELIC_SERVERLESS_MODE_ENABLED``false``true`, `false`This should be set to `true` so the agent will run in serverless mode
`NEW_RELIC_PACKAGE_REPORTING_ENABLED``true``true`, `false`Python agent package reporting should be set to `false` to improve cold start times
+ +You can find more environment variables in our [Python configuration documentation](/docs/apm/agents/python-agent/configuration/python-agent-configuration). +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED``false``true`, `false`Enable or disable distributed tracing
`NEW_RELIC_LAMBDA_HANDLER`Set to your function's original Handler value
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Environment variableDefault valueOptionsDescription
`NEW_RELIC_LAMBDA_EXTENSION_ENABLED``true``true`, `false` Enable or disable the extension
`NEW_RELIC_LICENSE_KEY`Your New Relic ingest key. This overrides Secrets Manager
`NEW_RELIC_LICENSE_KEY_SECRET``NEW_RELIC_LICENSE_KEY`Custom secret name in AWS Secrets Manager
`NEW_RELIC_LAMBDA_HANDLER`If you don't use New Relic's [manual wrapping method](https://github.com/newrelic/newrelic-lambda-layers?tab=readme-ov-file#note-on-performance-for-es-module-functions) this is your your function's handler.
`NEW_RELIC_DATA_COLLECTION_TIMEOUT`10sReduce timeout duration when for `Telemetry client error`
`NEW_RELIC_EXTENSION_LOGS_ENABLED``true``true`, `false`Enable or disable `NR_EXT` log lines
`NEW_RELIC_EXTENSION_LOG_LEVEL``info``info`, `debug`log level for NR_EXT log lines
`NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS``false``true`, `false`Send function logs
`NEW_RELIC_LOG_ENDPOINT`Set to https://log-api.newrelic.com/log/v
`NEW_RELIC_TELEMETRY_ENDPOINT`Set to [US endpoint](https://cloud-collector.newrelic.com/aws/lambda/v1)Optional [EU endpoint](https://github.com/newrelic/newrelic-lambda-extension/blob/3c4218dd7727d0b0467f24f0902b616b7f4e46b7/telemetry/client.go#L24-L27)
+ +See more environment variables for the New Relic extension in our [documentation](https://github.com/newrelic/newrelic-lambda-extension/blob/cf86fb53f0bd816e1d09d07f7b5c5ab4841010a0/config/config.go#L41-L55). + +
+
+ + + diff --git a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/containerized-images.mdx b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/containerized-images.mdx index dea21cbd0f1..4bfab79a60b 100644 --- a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/containerized-images.mdx +++ b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/containerized-images.mdx @@ -1,5 +1,5 @@ --- -title: Instrument your containerized image layer +title: Instrument your containerized function metaDescription: A guide for instrumenting your containerized image layer with New Relic. redirects: - /docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started/ @@ -8,15 +8,13 @@ freshnessValidatedDate: never import serverlessContainerizedImagesWithLambda from 'images/serverless_diagram_containerized-images-with-lambda.webp' -If you're using a containerized image for a Lambda function and want to monitor your application, you'll need to add New Relic to your code. For example, suppose you're a developer for a budgeting application and you're using a Lambda function to calculate account balances every time a customer clicks **See my balance**. You want to dive deep into any potential latencies. In that case, you'll need to add New Relic to your function, so every time a customer clicks **See my balance** your function runs, and New Relic does too. +If you're using a containerized image for a Lambda function and want to monitor your application, you'll need to add New Relic to your Dockerfile. For example, suppose you're a developer for a budgeting application and you're using a Lambda function to calculate account balances every time a customer clicks **See my balance**. You want to dive deep into any potential latencies. In that case, you'll need to add New Relic to your function, so every time a customer clicks **See my balance** your function runs, and New Relic does too. -First, you have to add New Relic's prebuilt layer to your code. From there, you'll need to push the image to your [AWS Elastic Container Registry](https://console.aws.amazon.com/ecr/home/). After you've pushed up your code combined with New Relic's prebuilt layer, you'll need to create a new function from the image you pushed to AWS ECR. - -To understand how our prebuilt layer works, take a look at this diagram. +Here's a diagram showing the process of adding New Relic to the Dockerfile so you can monitor your function: A diagram demonstrating how New Relic integrates with your Lambda containerized image. @@ -35,21 +33,43 @@ New Relic offers pre-built images that include our layer's different runtimes: J * [Java](https://gallery.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-java) * [Node.js](https://gallery.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-nodejs) * [Python](https://gallery.ecr.aws/x6n7b2o2/newrelic-lambda-layers-python) + * [Ruby](https://gallery.ecr.aws/x6n7b2o2/newrelic-lambda-layers-ruby) * [Extension-only](https://gallery.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-lambdaextension) -1. At the top of your Dockerfile, add the following code: +1. In your multi-stage Dockerfile, use New Relic's prebuilt image as an intermediate build stage. Then, copy New Relic's agent and extension from our prebuilt image into your final build stage. + +### Example + +Here is an example of the original Dockerfile merged with New Relic's prebuilt layer. This example uses a Node.js runtime. + +```dockerfile + +# Define the New Relic pre-built image +FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-nodejs:20 AS layer + +# Define the base image: +FROM public.ecr.aws/lambda/nodejs:20 + +# Copy New Relic Layer code +COPY --from=layer /opt/ /opt/ + +# Rest of your Dockerfile... +``` + +### Dockerfile examples based on runtime - - Java - Python - Node.js - Extension-only - - - + + Java + Python + Node.js + Ruby + Extension-only + + + - ``` + ```dockerfile FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-java:17-arm64 AS layer # Layer code @@ -59,7 +79,7 @@ New Relic offers pre-built images that include our layer's different runtimes: J - ```java + ```dockerfile FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-python:38-arm64 AS layer # Layer code @@ -69,7 +89,7 @@ New Relic offers pre-built images that include our layer's different runtimes: J - ```js + ```dockerfile FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-nodejs:20-arm64 AS layer # Layer code @@ -77,307 +97,49 @@ New Relic offers pre-built images that include our layer's different runtimes: J ``` - + + + ```dockerfile + FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-ruby:32-arm64 AS layer + + # Layer code + COPY --from=layer /opt/ /opt/ ``` + + + + + ```dockerfile FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-lambdaextension:x86 as layer # Layer code COPY --from=layer /opt/ /opt/ ``` - + ### Create an image - 1. After you add the New Relic pre-built layer to your Dockerfile, you'll need to build a new image from the Dockerfile. This new image will have your original code _and_ New Relic's layer. To do this, we recommend following the steps listed in the AWS guide, [Pushing a Docker image](https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html). - 2. Push the new image to your AWS Elastic Container Registry (ECR) repository for deployment. + 1. After you add the reference to New Relic's pre-built image to your Dockerfile, you'll need to build a new image from the modified Dockerfile. This new image will have your original code and New Relic's pre-built image. To do this, we recommend following the steps listed in the AWS guide, [Create a Lambda function using a container image](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html). + 2. Push the new image to your [AWS Elastic Container Registry](https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html) repository for deployment. + + +### Create a new Lambda function + + Using the image you pushed to AWS ECR, create a new Lambda function. For more information on creating this function, we recommend going back to the AWS guide: [Create a Lambda function](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html). ### Configure your Lambda function - 1. Create a new Lambda function using the image you pushed to AWS ECR. For more information on creating this function, we recommend reviewing the AWS guide: [Working with container images](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html). - 2. Configure the Lambda function with the same settings as your original function, but ensure you add any required environment variables for New Relic Lambda monitoring. See our [Environment variables](/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/containerized-images/#environment) for more information. - 3. Update your function's handler to point to the newly attached layer in `cmd` override for your function. You can do that using the instructions in these two docs: - * [Lambda console UI configuration](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/instrument-your-own/#console) + + 2. Configure the Lambda function with the same settings as your original function, but ensure you add any required environment variables for New Relic Lambda monitoring. See our [Environment variables](/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/configure-serverless-monitoring-aws-lambda/#environment) for more information. + 2. Update your function's handler to point to the newly attached layer in `cmd` override for your function. You can do that using the instructions in these two docs: + * [Lambda console UI configuration](/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/instrument-your-own/#console) * [Layerless instrumentation for Lambda monitoring](/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/enable-serverless-monitoring-aws-lambda-layerless) -## Environment variables [#environment] - -It's important to configure your new Lambda function with the New Relic environment variables that match your monitoring needs. Choose your runtime to see the available environment variables and our recommendations for default settings. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Environment variableDefault valueOptionsDescription
`NEW_RELIC_ACCOUNT_ID`Your New Relic account ID
`NEW_RELIC_TRUSTED_ACCOUNT_KEY`Your New Relic account ID or parent ID, if it exists
`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED``false``true`, `false`Enable or disable distributed tracing
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Environment variableDefault valueOptionsDescription
`NEW_RELIC_NO_CONFIG_FILE``false``true`, `false`The Node.js agent uses environment variables in Lambda, so this should be set to `true`
`NEW_RELIC_APP_NAME`Should be set but is not used in the New Relic UI. Instead, entity names come from the AWS integration.
`NEW_RELIC_LOG_ENABLED``false``true`,`false`Outputs agent logs to CloudWatch
`NEW_RELIC_LOG_LEVEL``info``fatal`, `error`, `warn`, `info`, `debug`, `trace`Agent log level
`NEW_RELIC_LOG``stdout``stdout`Agent log path should be stdout for the Node.js agent in serverless mode
`NEW_RELIC_USE_ESM``false``true`, `false`ESM functions that use async/await and not callbacks
`NEW_RELIC_NATIVE_METRICS_ENABLED``true``true`, `false`Should be set to false to reduce cold start duration. When set to `false` it does not collect VM metrics
- -You can find more environment variables in our [Node.js configuration documentation](/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/). - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Environment variable - -Default value -OptionsDescription
`NEW_RELIC_NO_CONFIG_FILE``false``true`, `false`Agent uses environment variables in Lambda so this should be set to true
`NEW_RELIC_APP_NAME`Should be set but is not used in the New Relic UI. Instead, entity names come from the AWS integration.
`NEW_RELIC_LOG``stderr``stderr`Agent log path should be `stderr `for the Python agent in serverless mode
`NEW_RELIC_LOG_LEVEL``info``critical`, `error`, `warning`, `info`, `debug`Agent log level
`NEW_RELIC_SERVERLESS_MODE_ENABLED` -`false` -`true`, `false`This should be set to `true` so the agent will run in serverless mode
`NEW_RELIC_PACKAGE_REPORTING_ENABLED``true``true`, `false`Python agent package reporting should be set to `false` to improve cold start times
- -You can find more environment variables in our [Python configuration documentation](/docs/apm/agents/python-agent/configuration/python-agent-configuration). - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Environment variableDefault valueOptionsDescription
`NEW_RELIC_PRIMARY_APPLICATION_ID`Your New Relic account ID
`NEW_RELIC_DEBUG``false``true`, `false`Agent log level
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Environment variableDefault valueOptionsDescription
`NEW_RELIC_LAMBDA_EXTENSION_ENABLED``true``true`, `false` Enable or disable the extension
`NEW_RELIC_LICENSE_KEY`Your New Relic ingest key. This overrides Secrets Manager
`NEW_RELIC_LICENSE_KEY_SECRET``NEW_RELIC_LICENSE_KEY`Custom secret name in AWS Secrets Manager
`NEW_RELIC_LAMBDA_HANDLER`If you don't use New Relic's [manual wrapping method](https://github.com/newrelic/newrelic-lambda-layers?tab=readme-ov-file#note-on-performance-for-es-module-functions) this is your your function's handler.
`NEW_RELIC_DATA_COLLECTION_TIMEOUT`10sReduce timeout duration when for `Telemetry client error`
`NEW_RELIC_EXTENSION_LOGS_ENABLED``true``true`, `false`Enable or disable `NR_EXT` log lines
`NEW_RELIC_EXTENSION_LOG_LEVEL``info``info`, `debug`log level for NR_EXT log lines
`NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS``false``true`, `false`Send function logs
- -See more environment variables for the New Relic extension in our [documentation](https://github.com/newrelic/newrelic-lambda-extension/blob/cf86fb53f0bd816e1d09d07f7b5c5ab4841010a0/config/config.go#L41-L55). - -
-
\ No newline at end of file diff --git a/src/images/serverless_diagram_containerized-images-with-lambda.webp b/src/images/serverless_diagram_containerized-images-with-lambda.webp index fc9d447976e..fa4e833b059 100644 Binary files a/src/images/serverless_diagram_containerized-images-with-lambda.webp and b/src/images/serverless_diagram_containerized-images-with-lambda.webp differ