Gathering detailed insights and metrics for serverless-newrelic-lambda-layers
Gathering detailed insights and metrics for serverless-newrelic-lambda-layers
Gathering detailed insights and metrics for serverless-newrelic-lambda-layers
Gathering detailed insights and metrics for serverless-newrelic-lambda-layers
A Serverless plugin to install New Relic's AWS Lambda layers without requiring a code change.
npm install serverless-newrelic-lambda-layers
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
56 Stars
697 Commits
51 Forks
18 Watching
42 Branches
53 Contributors
Updated on 28 Nov 2024
TypeScript (99.61%)
JavaScript (0.27%)
Shell (0.12%)
Cumulative downloads
Total Downloads
Last day
-14.3%
5,659
Compared to previous day
Last week
24.6%
39,096
Compared to previous week
Last month
6.2%
154,262
Compared to previous month
Last year
33.5%
1,796,155
Compared to previous year
7
A Serverless plugin to add New Relic observability using AWS Lambda Layers without requiring a code change.
With NPM:
1npm install --save-dev serverless-newrelic-lambda-layers
(Note: this plugin's production dependencies are now defined as peer dependencies. NPM v7 and later will install missing peer dependencies automatically, but v6 does not.)
With yarn:
1yarn add --dev serverless-newrelic-lambda-layers
Add the plugin to your serverless.yml
:
1plugins: 2 - serverless-newrelic-lambda-layers
This plugin should come last in your plugin ordering, particularly if you're also using plugins such as serverless-plugin-typescript
or serverless-webpack
.
If you don't yet have a New Relic account, sign up here.
Grab your New Relic Account ID,
your New Relic Personal API Key
and plug them into your serverless.yml
:
1custom: 2 newRelic: 3 accountId: your-new-relic-account-id-here 4 apiKey: your-new-relic-personal-api-key-here
Deploy:
1sls deploy
And you're all set.
This plugin wraps your handlers without requiring a code change. If you're currently using a New Relic agent, you can remove the wrapping code you currently have and this plugin will do it for you automatically.
The following config options are available via the newRelic
section of the custom
section of your serverless.yml
:
accountId
(required)Your New Relic Account ID.
1custom: 2 newRelic: 3 accountId: your-account-id-here
apiKey
(required)Your New Relic Personal API Key.
1custom: 2 newRelic: 3 apiKey: your-api-key-here
If your function's source is committed to version control, you can avoid committing your license key by including it in your serverless.yml as a variable. See the Serverless docs on template variables for more information.
nrRegion
(required for EU; optional for US)If your New Relic account is based in the EU, make sure to specify your nrRegion in the custom block:
1custom: 2 newRelic: 3 nrRegion: 'eu'
linkedAccount
(optional)A label for the New Relic Linked Account. This is how this integration will
appear in New Relic. If not set, it will default to "New Relic Lambda Integration -
1custom: 2 newRelic: 3 linkedAccount: your-linked-account-name
trustedAccountKey
(optional)Only required if your New Relic account is a sub-account. This needs to be the account ID for the root/parent account.
1custom: 2 newRelic: 3 trustedAccountKey: your-parent-account-id
debug
(optional)Whether or not to enable debug mode. Must be a boolean value. This sets the log level to debug.
1custom: 2 newRelic: 3 debug: true
enableExtension
(optional)Allows your function to deliver its telemetry to New Relic via AWS Lambda Extension. Defaults to true
, so it can be omitted. To avoid delivering your telemetry via the extension, set to false
.
1custom: 2 newRelic: 3 enableExtension: true
enableFunctionLogs
(optional)Allows your function to deliver all of your function logs to New Relic via AWS Lambda Extension. This would eliminate the need for a CloudWatch log subscription + the NR log ingestion Lambda function. This method of log ingestion is lower-cost, and offers faster time to glass.
1custom: 2 newRelic: 3 enableFunctionLogs: true
enableExtensionLogs
(optional)The New Relic Lambda Extension writes diagnostic logs by default. If you'd prefer to mute them, set this to false
. (Defaults to true
.)
1custom: 2 newRelic: 3 enableExtensionLogs: false
logEnabled
(optional)Enables logging when using CloudWatch-based telemetry transport with the newrelic-log-ingestion Lambda function. Defaults to false
enableIntegration
(optional)Allows the creation of New Relic aws cloud integration when absent. Defaults to false
. If an integration already exists for your AWS account,you can omit this.
1custom: 2 newRelic: 3 enableIntegration: true
logLevel
(optional)Sets a log level on all functions. Possible values: 'fatal'
, 'error'
, 'warn'
, 'info'
, 'debug'
, 'trace'
or 'silent'
. Defaults to 'error'
You can still override log level on a per function basis by configuring environment variable NEW_RELIC_LOG_LEVEL
.
1custom: 2 newRelic: 3 logLevel: debug
Logging configuration is considered in the following order:
NEW_RELIC_LOG_LEVEL
environmentNEW_RELIC_LOG_LEVEL
environmentlogLevel
propertydebug
flagmanualWrapping
(optional)Functions with many dependencies may experience longer cold start times with dynamic wrapping. One possible remediation is to wrap the function manually, and bypass the no-code-change wrapping. If you enable this option, you'll need to require
(or, for ESM, import
) the New Relic Node Agent, and wrap the body of your handler function. You would still be able to take advantage of the easy installation of the agent via Lambda Layers, and still have telemetry transported to New Relic via the Lambda Extension. We recommend that you include the New Relic Node Agent as a devDependency for local development, and omit it from the dependencies you deploy. Defaults to false
.
1custom: 2 newRelic: 3 manualWrapping: true
customRolePolicy
(optional)Specify an alternative IAM role policy ARN for this integration here if you do not want to use the default role policy.
1custom: 2 newRelic: 3 customRolePolicy: your-custom-role-policy-arn
stages
(optional)An array of stages that the plugin will be included for. If this key is not specified then all stages will be included.
1custom: 2 newRelic: 3 stages: 4 - prod
include
(optional)An array of functions to include for automatic wrapping. (You can set include
or exclude
options, but not both.)
1custom: 2 newRelic: 3 include: 4 - include-only-func 5 - another-included-func
exclude
(optional)An array of functions to exclude from automatic wrapping. (You can set include
or exclude
options, but not both.)
1custom: 2 newRelic: 3 exclude: 4 - excluded-func-1 5 - another-excluded-func
layerArn
(optional)Pin to a specific layer version. The latest layer ARN is automatically fetched from the New Relic Layers API
1custom: 2 newRelic: 3 layerArn: arn:aws:lambda:us-east-1:451483290750:layer:NewRelicPython37:2
cloudWatchFilter
(optional)Provide a list of quoted filter terms for the CloudWatch log subscription to the newrelic-log-ingestion Lambda. Combines all terms into an OR filter. Defaults to "NR_LAMBDA_MONITORING" if not set. Use "*" to capture all logs
1custom: 2 newRelic: 3 cloudWatchFilter: 4 - "NR_LAMBDA_MONITORING" 5 - "trace this" 6 - "ERROR"
If you want to collect all logs:
1custom: 2 newRelic: 3 cloudWatchFilter: "*"
Be sure to set the LOGGING_ENABLED
environment variable to true
in your log
ingestion function. See the aws-log-ingestion documentation for details.
prepend
(optional)Whether or not to prepend the New Relic layer. Defaults to false
which appends the layer.
1custom: 2 newRelic: 3 prepend: true
logIngestionFunctionName
(optional)Only required if your New Relic log ingestion function name is different from newrelic-log-ingestion
.
1custom: 2 newRelic: 3 logIngestionFunctionName: log-ingestion-service
disableAutoSubscription
(optional)Only required if you want to disable auto subscription.
1custom: 2 newRelic: 3 disableAutoSubscription: true
disableLicenseKeySecret
(optional)Only required if you want to disable creating license key in AWS Secrets Manager. Setting this as true
would create NEW_RELIC_LICENSE_KEY environment variable for the New Relic Lambda Extension to access.
1custom: 2 newRelic: 3 disableLicenseKeySecret: true
enableDistributedTracing
(optional)Only required if you want to disable distributed tracing.
1custom: 2 newRelic: 3 enableDistributedTracing: false
javaNewRelicHandler
(optional)Java runtimes only. Only required if you are implementing the RequestStreamHandler
interface.
Defaults to RequestHandler
interface.
1custom: 2 newRelic: 3 javaNewRelicHandler: handleStreamsRequest
proxy
(optional)This plugin makes various HTTP requests to public APIs in order to retrieve data about the New Relic and cloud provider accounts. If you are behind a proxy when this plugin runs, the HTTP agent needs the proxy information to connect to those APIs. Use the given URL as a proxy for HTTP requests.
1custom: 2 newRelic: 3 proxy: http://yourproxy.com:8080
This plugin currently supports the following AWS runtimes:
examples/nodejs/serverless.yml
based on what you are planning to testgenerate:test:case
1# Example 2npm run generate:test:case
tests/fixtures/example.service.input.json
to test case e.g. tests/fixtures/log-level.service.input.json
tests/fixtures/example.service.output.json
for test case e.g. tests/fixtures/log-level.service.output.json
1# Example 2npm run test
No vulnerabilities found.
No security vulnerabilities found.