Giter VIP home page Giter VIP logo

newrelic-lambda-cli's Introduction

newrelic-lambda-cli

A CLI to install the New Relic AWS Lambda integration and layers.

Features

  • Installs the New Relic AWS Lambda integration onto your AWS account
  • Installs and configures a New Relic AWS Lambda layer onto your AWS Lambda functions
  • Automatically selects the correct New Relic layer for your function's runtime and region
  • Wraps your AWS Lambda functions without requiring a code change
  • Supports Node.js and Python AWS LAmbda runtimes
  • Easily uninstall the AWS Lambda layer with a single command

Runtimes Supported

  • nodejs10.x
  • nodejs12.x
  • python2.7
  • python3.6
  • python3.7
  • python3.8

Requirements

Recommendations

  • Install the AWS CLI and configure your environment with aws configure

Installation

pip install newrelic-lambda-cli

Or clone this repo and run:

python setup.py install

Usage

AWS Lambda Integration

Install Integration

In order to instrument your AWS Lambda functions using New Relic you must first install the New Relic AWS Lambda integration and the log ingestion function in the AWS region in which your Lambda functions are located. If you have Lambda functions located in multiple regions you can run the command multiple times specifying the AWS regions with --aws-region <your aws region here>. This command only needs to be run once per AWS region. By default this command will look for a default AWS profile configured via the AWS CLI.

newrelic-lambda integrations install \
    --nr-account-id <account id> \
    --nr-api-key <api key> \
    --linked-account-name <linked account name>
Option Required? Description
--nr-account-id or -a Yes The New Relic Account ID for this integration. Can also use the NEW_RELIC_ACCOUNT_ID environment variable.
--nr-api-key or -k Yes Your New Relic User API Key. Can also use the NEW_RELIC_API_KEY environment variable.
--linked-account-name or -l Yes A label for the New Relic Linked ACcount. This is how this integration will appear in New Relic.
--nr-region No The New Relic region to use for the integration. Can use the NEW_RELIC_REGION environment variable. Defaults to us.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region for the integration. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.
--aws-role-policy No Specify an alternative IAM role policy ARN for this integration.

Uninstall Integration

newrelic-lambda integrations uninstall
Option Required? Description
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region for the integration. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

AWS Lambda Layers

Install Layer

newrelic-lambda layers install \
    --function <name or arn> \
    --nr-account-id <new relic account id>
Option Required? Description
--function or -f Yes The AWS Lambda function name or ARN in which to add a layer.
--nr-account-id or -a Yes The New Relic Account ID this function should use. Can also use the NEW_RELIC_ACCOUNT_ID environment variable.
--layer-arn or -l No Specify a specific layer version ARN to use. This is auto detected by default.
--upgrade or -u No Permit upgrade to the latest layer version for this region and runtime.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region this function is located. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

Uninstall Layer

newrelic-lambda layers uninstall --function <name or arn>
Option Required? Description
--function or -f Yes The AWS Lambda function name or ARN in which to remove a layer.
--layer-arn or -l No Specify a specific layer version ARN to remove. This is auto detected by default.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region this function is located. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

AWS Lambda Functions

List Functions

newrelic-lambda functions list

List functions with layer installed:

newrelic-lambda functions list --filter installed
Option Required? Description
--filter or -f No Filter to be applied to list of functions. Options are all, installed and not-installed. Defaults to all.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region to use for htis command. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

NewRelic Log Subscription

Install Log Subscription

newrelic-lambda subscriptions install \--function <name or arn>
Option Required? Description
--function or -f Yes The AWS Lambda function name or ARN in which to add a log subscription.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region this function is located. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

Uninstall Log Subscription

newrelic-lambda subscriptions uninstall --function <name or arn>
Option Required? Description
--function or -f Yes The AWS Lambda function name or ARN in which to remove a log subscription.
--aws-profile or -p No The AWS profile to use for this command. Can also use AWS_PROFILE. Defaults to default. Will also check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if not using AWS CLI.
--aws-region or -r No The AWS region this function is located. Can use AWS_DEFAULT_REGION environment variable. Defaults to AWS profile default.

Contributing

We welcome code contributions (in the form of pull requests) from our user community. Before submitting a pull request please review these guidelines.

Following these helps us efficiently review and incorporate your contribution and avoid breaking your code with future changes to the agent.

Code style

We use the black code formatter.

pip install black

We recommend using it with pre-commit:

pip install pre-commit
pre-commit install

Using these together will auto format your git commits.

Running Tests

python setup.py test

newrelic-lambda-cli's People

Contributors

ardias avatar arvdias avatar bmcfeely avatar ewindisch avatar gene5ive avatar hmacdonald-nr avatar igoratron avatar katiebayes avatar kolanos avatar mattwhelan avatar salvatorious avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.