Skip to content

Julien4218/newrelic-cli

Β 
Β 

Repository files navigation

Community Project header

newrelic-cli

Testing Security Scan Go Report Card GoDoc License CLA assistant Release

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.

The latest New Relic CLI documentation is available here.

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.

Installation

Installation options are available for various platforms.

MacOS

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.

Scoop

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

Chocolatey

Currently the newrelic-cli is in review with in the Chocolatey system, and should be published in the next few days. That means that you must include the version spec, as follows.

choco install newrelic-cli

Standalone installer

A standalone MSI installer is available on the GitHub releases page. 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

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 created on the GitHub releases page 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.

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.13.0+
  • 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

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

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].

Open Source License

This project is distributed under the Apache 2 license.

About

The New Relic Command Line Interface

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 88.1%
  • Makefile 7.6%
  • Shell 3.8%
  • Other 0.5%