• Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The New Relic Command Line Interface

Community Project header

newrelic-cli

Testing Go Report Card GoDoc License CLA assistant Release Homebrew

Docker Stars Docker Pulls Docker Size Docker Version

The New Relic CLI is an officially supported command line interface for New Relic, released as part of the Developer Toolkit.

Overview

The New Relic CLI is a project to consolidate some of the tools that New Relic offers for managing resources. Current scope is limited while the framework is being developed, but the tool as-is does perform a subset of tasks.

  • Entity Search: Search for entities across all your New Relic accounts
  • Entity Tagging: Manage tags across all of your entities
  • Deployment Markers: Easily record an APM Application deployment within New Relic.

Getting Started

For a quick guide on getting started with the New Relic CLI, see our Getting Started page.

New Relic CLI Documentation

The latest New Relic CLI documentation is available in the repository's docs directory.

Installation & Upgrades

Installation options are available for various platforms. If you're running an older version of the CLI you can use these commands to update to the latest version.

MacOS

Automated install

curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash

Homebrew

Install the New Relic CLI on MacOS via homebrew. With homebrew installed, run:

brew install newrelic-cli

Windows

Installation is supported on 64-bit Windows.

Automated install

[Net.ServicePointManager]::SecurityProtocol = 'tls12, tls'; (New-Object System.Net.WebClient).DownloadFile("https://download.newrelic.com/install/newrelic-cli/scripts/install.ps1", "$env:TEMP\install.ps1"); & $env:TEMP\install.ps1

Scoop

scoop bucket add newrelic-cli https://github.com/newrelic/newrelic-cli.git
scoop install newrelic-cli

Chocolatey

choco install newrelic-cli

Standalone installer

A standalone MSI installer is available on the New Relic download site. You can download the installer for the latest version here.

Powershell

Silent installation of the latest version of the CLI can be achieved via the follwing Powershell command:

(New-Object System.Net.WebClient).DownloadFile("https://github.com/newrelic/newrelic-cli/releases/latest/download/NewRelicCLIInstaller.msi", "$env:TEMP\NewRelicCLIInstaller.msi"); `
msiexec.exe /qn /i "$env:TEMP\NewRelicCLIInstaller.msi" | Out-Null; `

Linux

Automated install

curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash

Snapcraft

Linux binaries can be installed via Snapcraft. With the snapd daemon installed, run:

sudo snap install newrelic-cli

Pre-built binaries

Pre-built binaries are available for all of the above platforms. You can download the latest releases here. The binaries and their checksums are signed and can be verified against the Developer Toolkit team's public PGP key.

Verify that the fingerprint for the downloaded key matches the following:

gpg --fingerprint [email protected]

5961 D131 BB2C 5C6B 42B1  4D0F 92AD A76A 30A3 F1FD

When verifying pre-built binaries and checksums, use the long format (the short format is not secure). For example:

gpg --keyid-format long --verify checksums.txt.sig checksums.txt

Docker

There is an official docker image that can be utilized for running commands as well.

Example Usage

Querying an APM application (using the Docker image)

# Pull the latest container
$ docker pull newrelic/cli

# Run the container interactively, remove it once the command exists
# Also must pass $NEW_RELIC_API_KEY to the container
$ docker run -it --rm \
    -e NEW_RELIC_API_KEY \
    newrelic/cli \
    apm application get --name WebPortal --accountId 2508259

[
  {
    "AccountID": 2508259,
    "ApplicationID": 204261368,
    "Domain": "APM",
    "EntityType": "APM_APPLICATION_ENTITY",
    "GUID": "MjUwODI1OXxBUE18QVBQTElDQVRJT058MjA0MjYxMzY4",
    "Name": "WebPortal",
    "Permalink": "https://one.newrelic.com/redirect/entity/MjUwODI1OXxBUE18QVBQTElDQVRJT058MjA0MjYxMzY4",
    "Reporting": true,
    "Type": "APPLICATION"
  }
]

See the Getting Started guide for a more in-depth introduction to the capabilities of the New Relic CLI.

Getting Help

In order to get help about what commands are available, the trusty --help flag is here to assist. Alternatively, using just the help subcommand also works.

newrelic --help
newrelic help

Help is also available for the nested sub-commands. For example, the with the following command, you can retrieve help for the apm sub-command.

newrelic apm --help
newrelic help apm

Using the CLI in this way, users are able to inspect what commands are available, with some instruction on their usage.

Patterns

Throughout the help, you may notice common patterns. The term describe is used to perform list or get operations, while the create and delete terms are used to construct or destroy an item, respectively.

Development

Requirements

  • Go 1.18+
  • GNU Make
  • git

Building

The newrelic command will be built in bin/ARCH/newrelic, where ARCH is either linux, darwin, or windows, depending on your build environment. You can run it directly from there or install it by moving it to a directory in your PATH.

# Default target is 'build'
$ make

# Explicitly run build
$ make build

# Locally test the CI build scripts
# make build-ci

Testing

Before contributing, all linting and tests must pass. Tests can be run directly via:

# Tests and Linting
$ make test

# Only unit tests
$ make test-unit

# Only integration tests
$ make test-integration

Working with recipes

Core recipe library

A core library of installation recipes is included with the CLI for use within the install command. Recipe files are syndicated from open-install-library and embedded in the CLI binary at release time. To fetch the latest recipe library while developing, the following make target can be used:

make recipes

Recipe files are stored in internal/install/recipes/files. Once files have been fetched, they will be included in future CLI builds. If a particular version of the recipe library is desired, the archive download URL can be passed to the make target via the RECIPES_ARCHIVE_URL option:

make recipes RECIPES_ARCHIVE_URL=https://github.com/newrelic/open-install-library/releases/download/v0.50.0/recipes.zip

To clean recipe files, use the recipes-clean target:

make recipes-clean

Custom recipe files

A path can also be passed to the --localRecipes flag when running the install command. This will bypass the methods described above and load files from the designated path.

Experimenting (internal New Relic usage only)

Using A/B tests, New Relic developers have the ability to gradually roll out new features.

Define an experiment

With access to Split.io, internal New Relic developers can create new A/B tests. Upon creating one, reference the exact name of the experiment in internal/split/constants.go. Make sure this is the exact name of the experiment in Split.io.

Retrieve treatments

You can retrieve the status of the treatment by using the SplitService.

// Retrieve a single treatment given an experiment (split)
treatment := split.SplitService.Get(split.VirtuosoCLITest)

if treatment == "on" {
  // insert code here to show on treatment
} else if treatment == "off" {
  // insert code here to show off treatment
} else {
  // insert your control treatment code here
}

// Retrieve multiple treatments given a list of experiments (splits)
splits := []string{split.VirtuosoCLITest, split.VirtuosoCliTest2}
treatments := split.SplitService.GetAll(splits)
for split, treatment := range treatments {
    fmt.Printf("Treatment for feature %s is %s\n", split, treatment)
    // Evaluate treatments
}

Commit Messages

Using the following format for commit messages allows for auto-generation of the CHANGELOG:

Format:

<type>(<scope>): <subject>

Type Description Change log?
chore Maintenance type work No
docs Documentation Updates Yes
feat New Features Yes
fix Bug Fixes Yes
refactor Code Refactoring No

Scope

This refers to what part of the code is the focus of the work. For example:

General:

  • build - Work related to the build system (linting, makefiles, CI/CD, etc)
  • release - Work related to cutting a new release

Package Specific:

  • newrelic - Work related to the New Relic package
  • http - Work related to the internal/http package
  • alerts - Work related to the pkg/alerts package

Generating CLI Documentation

Note: This requires the repo to be in your GOPATH (godoc issue)

$ make docs

Community Support

New Relic hosts and moderates an online forum where you can interact with New Relic employees as well as other customers to get help and share best practices.

  • Roadmap - As part of the Developer Toolkit, the roadmap for this project follows the same RFC process
  • Issues or Enhancement Requests - Issues and enhancement requests can be submitted in the Issues tab of this repository. Please search for and review the existing open issues before submitting a new issue.
  • Contributors Guide - Contributions are welcome (and if you submit a Enhancement Request, expect to be invited to contribute it yourself 😁).
  • Community discussion board - Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub.

Please do not report issues with the CLI to New Relic Global Technical Support. Instead, visit the Explorers Hub for troubleshooting and best-practices.

Issues / Enhancement Requests

Issues and enhancement requests can be submitted in the Issues tab of this repository. Please search for and review the existing open issues before submitting a new issue.

Contributing

Contributions are welcome (and if you submit a Enhancement Request, expect to be invited to contribute it yourself 😁). Please review our Contributors Guide.

Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at [email protected].

Other Resources

There are a handful of other useful tools that this does not replace. Here are some useful links to other tools that you might be interested in using at this time.

  • NR1 CLI: Command line interface for managing development workflows for custom Nerdpacks on New Relic One.
  • New Relic Lambda CLI: A CLI to install the New Relic AWS Lambda integration and layers.
  • New Relic Diagnostics: A utility that automatically detects common problems with New Relic agents.

Open Source License

This project is distributed under the Apache 2 license.

More Repositories

1

centurion

A mass deployment tool for Docker fleets
Ruby
1,744
star
2

newrelic-ruby-agent

New Relic RPM Ruby Agent
Ruby
1,180
star
3

node-newrelic

New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com.
JavaScript
927
star
4

go-agent

New Relic Go Agent
Go
719
star
5

rusty-hog

A suite of secret scanners built in Rust for performance. Based on TruffleHog (https://github.com/dxa4481/truffleHog) which is written in Python.
Rust
447
star
6

sidecar

Gossip-based service discovery. Docker native, but supports static discovery, too.
Go
259
star
7

elixir_agent

New Relic's Open Source Elixir Agent
Elixir
253
star
8

terraform-provider-newrelic

Terraform provider for New Relic
Go
201
star
9

rpm_contrib

Extra Instrumentation for the New Relic RPM Gem
192
star
10

newrelic-java-agent

The New Relic Java agent
Java
183
star
11

docs-website

Source code for @newrelic docs. We welcome pull requests and questions on our docs!
MDX
170
star
12

newrelic-python-agent

New Relic Python Agent
Python
156
star
13

newrelic_aws_cloudwatch_plugin

New Relic AWS Cloudwatch Plugin
Ruby
154
star
14

check_docker

A Go Nagios check for Docker
Go
126
star
15

newrelic_api

Documentation, Active Resource Helper, and test code for the RPM REST API
Ruby
119
star
16

newrelic-quickstarts

New Relic One quickstarts help accelerate your New Relic journey by providing immediate value for your specific use cases.
TypeScript
109
star
17

nri-flex

An application-agnostic, all-in-one New Relic integration integration
Go
107
star
18

opensource-website

Source code for New Relic's Opensource site.
JavaScript
105
star
19

newrelic-opentelemetry-examples

Examples for sending OpenTelemetry sourced data to New Relic.
Java
103
star
20

newrelic-php-agent

The New Relic PHP Agent
C
103
star
21

infrastructure-agent

New Relic Infrastructure Agent
Go
102
star
22

helm-charts

Helm charts for New Relic applications
Smarty
95
star
23

infrastructure-agent-ansible

Ansible role for installing New Relic Infrastructure agent
Python
95
star
24

nr1-workshop

Self-paced training workshop for the NR1 CLI/SDK
JavaScript
85
star
25

newrelic_mysql_java_plugin

MySQL Metrics Plugin
Java
79
star
26

newrelic-browser-agent

New Relic Browser Agent
HTML
75
star
27

newrelic-lambda-extension

An AWS Lambda Extension to collect, enhance and transport telemetry to New Relic for AWS Lambda functions without requiring an external transport such as CloudWatch Logs or Kinesis.
Go
74
star
28

newrelic-dotnet-agent

The New Relic .NET language agent.
C#
74
star
29

newrelic-node-nextjs

New Relic Next.js instrumentation for the Node Agent
JavaScript
73
star
30

newrelic-client-go

New Relic Client for the Go programming language
Go
68
star
31

entity-definitions

The definition files contained in this repository are mappings between the telemetry attributes NewRelic ingests, and the entities users can interact with. If you have telemetry from any source that is not supported out of the box, you can propose a mapping for it by opening a PR.
JavaScript
67
star
32

node-native-metrics

Optional native module for collecting low-level Node & V8 metrics
C++
58
star
33

k8s-webhook-cert-manager

Generate certificate suitable for use with any Kubernetes Mutating Webhook.
Shell
58
star
34

c-sdk

New Relic C SDK
C
57
star
35

serverless-newrelic-lambda-layers

A Serverless plugin to install New Relic's AWS Lambda layers without requiring a code change.
TypeScript
55
star
36

newrelic-node-apollo-server-plugin

JavaScript
53
star
37

deployment-marker-action

Github Action for recording a Deployment Marker in New Relic
Shell
50
star
38

aws-log-ingestion

AWS Serverless Application that sends log data from CloudWatch Logs to New Relic Infrastructure - Cloud Integrations.
Python
50
star
39

absinthe-schema-stitching-example

Absinthe Schema Stitching Example
Elixir
49
star
40

nr1-cloud-optimize

NR1 Cloud Optimize allows you to Identify right-sizing opportunities and potential savings of your AWS, GCP, and Azure instances across your cloud environment.
JavaScript
48
star
41

newrelic-lambda-cli

A CLI to install the New Relic AWS Lambda integration and layers.
Python
47
star
42

infra-integrations-sdk

New Relic Infrastructure Integrations SDK
Go
45
star
43

go_nagios

Go lang package for writing Nagios checks
Go
43
star
44

newrelic-kubernetes-operator

Operator to create New Relic configuration in Kubernetes
Go
42
star
45

dPerf

Distributed Mobile CPU Profiling
Objective-C
41
star
46

newrelic-telemetry-sdk-go

Go library for sending telemetry data to New Relic
Go
40
star
47

newrelic-diagnostics-cli

NrDiag is a command line diagnostics tool for New Relic Products that was created by and is maintained by New Relic Global Technical Support
Go
39
star
48

developer-website

Source code for the New Relic Developer Site.
MDX
39
star
49

newrelic-telemetry-sdk-java

Java library for sending telemetry data to New Relic
Java
39
star
50

el-dorado-ui

Graph db query and rendering suitable for visualization of complex process structures
Ruby
37
star
51

newrelic-ruby-kata

Using New Relic and Heroku, see how many things you can find and fix to make this app perform fast!
Ruby
35
star
52

micrometer-registry-newrelic

ARCHIVED. TO SEND MICROMETER METRICS TO NEW RELIC, FOLLOW THE DIRECTION IN THE README.md. Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Java
35
star
53

newrelic-lambda-layers

Source code and utilities to build and publish New Relic's public AWS Lambda layers.
Shell
34
star
54

newrelic_microsoft_sqlserver_plugin

New Relic Microsoft SQL Server Plugin
C#
33
star
55

nri-prometheus

Fetch metrics in the Prometheus metrics inside or outside Kubernetes and send them to the New Relic Metrics platform.
Go
33
star
56

nr1-status-pages

NR1 Status Pages allows you to collect and display the statuses of key dependencies in one place.
JavaScript
33
star
57

nr-openai-observability

Easy to install OpenAI GPT monitoring tool.
Python
33
star
58

nri-kubernetes

New Relic integration for Kubernetes
Go
33
star
59

papers

Validates licenses of your Rails dependencies against a whitelist
Ruby
31
star
60

opentelemetry-exporter-go

New Relic's Golang OpenTelemetry Exporter
Go
30
star
61

newrelic-jfr-core

JFR library that adapts JFR events to the New Relic Telemetry SDK
Java
30
star
62

tutone

Generate Golang code from GraphQL schema introspection
Go
30
star
63

extends_newrelic_rpm

Gems that extend New Relic's Ruby agent (newrelic_rpm), linked via git submodules
Ruby
29
star
64

newrelic_plugin

New Relic Ruby Plugin Agent SDK
Ruby
29
star
65

newrelic-telemetry-sdk-python

A python library to send data to New Relic!
Python
29
star
66

infrastructure-agent-chef

Chef cookbook for installing New Relic Infrastructure agent
Ruby
28
star
67

nrjmx

Command line tool to connect to a JMX server and retrieve the MBeans it exposes.
Java
28
star
68

fluentd-examples

Sample FluentD configs
27
star
69

newrelic-fluent-bit-output

A Fluent Bit output plugin that sends logs to New Relic
Go
26
star
70

dkenv

A docker version switcher
Go
26
star
71

newrelic-unix-monitor

Monitoring service for Unix (AIX, Linux, HP-UX, MacOS, Solaris) systems
Java
26
star
72

marlowe

Experimental project for investigating interesting visualizations of APM data
JavaScript
25
star
73

wiki-sync-action

A GitHub Action that synchronizes the contents of a directory to the repository's Wiki.
Shell
25
star
74

futurestack14_badge

Source code for the badges from New Relic's FutureStack 2014 conference
Squirrel
24
star
75

nr-jenkins-plugin

Jenkins Plugin to send metrics to New Relic
Java
24
star
76

newrelic-telemetry-sdk-rust

Rust library for sending telemetry data to New Relic
Rust
23
star
77

quickstarts-synthetics-library

Repositories containing example/templated synthetic scripts for use in New Relic.
JavaScript
23
star
78

k8s-metadata-injection

Kubernetes metadata injection for New Relic APM to make a linkage between APM and Infrastructure data.
Go
23
star
79

newrelic-monolog-logenricher-php

Monolog components to enable New Relic Logs
PHP
22
star
80

agent_sdk_samples

Sample wrappers and code for the New Relic Agent SDK
C
22
star
81

nr1-learn-nrql

NR1 learn NRQL helps New Relic Customers quickly learn our custom query language - NRQL
JavaScript
21
star
82

nri-nginx

New Relic Infrastructure Nginx Integration
Go
21
star
83

nr1-slo-r

NR1 SLO-R allows you to define, calculate and report on service-level objective (SLO) attainment.
JavaScript
21
star
84

newrelic-airflow-plugin

Send airflow metrics to New Relic!
Python
20
star
85

newrelic-python-kata

Newrelic Python Kata
Python
20
star
86

newrelic_plugins_chef

Ruby
20
star
87

metrics_publish_java

New Relic Java Plugin Agent SDK
Java
20
star
88

newrelic-node-log-extensions

Source for the New Relic Node.js log framework extensions
JavaScript
20
star
89

newrelic-cordova-plugin

A Cordova plugin for the New Relic Mobile SDKs
JavaScript
19
star
90

newrelic-logenricher-dotnet

Extensions supporting New Relic Logging (Logs In Context)
C#
19
star
91

infrastructure-bundle

New Relic Infrastructure containerised agent bundle
Go
19
star
92

newrelic-cordova-ios

A PhoneGap / Cordova plugin for New Relic's iOS SDK
Objective-C
19
star
93

open-install-library

New Relic's open instrumentation installation recipe database and service
Shell
19
star
94

gatsby-theme-newrelic

Source code for New Relic's Gatsby site theme.
JavaScript
19
star
95

nr1-browser-analyzer

NR1 Browser Analyzer allows you to understand the impact and performance of your website.
JavaScript
18
star
96

nr1-quickstarts

[ARCHIVED] Community repository of New Relic dashboards, alerts, and installation instructions.
JavaScript
18
star
97

supervisor-remote-logging

Use supervisord to relay your application's stdout/stderr to syslog.
Python
18
star
98

webinar

Contains the sample code for the "Best Practices for Measuring Your Code Pipeline" webinar
18
star
99

video-agent-roku

New Relic Agent for Roku
Brightscript
16
star
100

ruby-metaprogramming-challenge

A fun metaprogramming challenge created at New Relic
Ruby
16
star