---
title: Get started with the New Relic CLI
source: https://docs.newrelic.com/docs/new-relic-solutions/tutorials/new-relic-cli
---

Access the New Relic platform from the comfort of your terminal. You can use the New Relic CLI to manage entity tags, define workloads, record deployment markers, and much more. In short, you can use the CLI to automate common tasks in your DevOps workflow. This guide walks you through the essentials of New Relic CLI, from install and configuration to basic usage.

## Before you begin

For this guide you just need:

-   Your New Relic [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key).
-   An [instrumented application](https://docs.newrelic.com/docs/agents/manage-apm-agents/installation/install-agent) in your New Relic account.

## Install the New Relic CLI

Download the New Relic CLI for your operating system, as described below. You can also download [pre-built binaries](https://github.com/newrelic/newrelic-cli/releases) for all platforms, including .deb and .rpm packages, and our Windows x64 .msi installer.

**Linux**

Using [Snapcraft](https://snapcraft.io/), run:

````sh
sudo snap install newrelic-cli
```

<DNT>
  **macOS**
</DNT>

Using [Homebrew](https://brew.sh/), run:

```sh
brew install newrelic-cli
```

<DNT>
  **Windows**
</DNT>

Using [Scoop](https://scoop.sh/), run:

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

````

## Create your New Relic CLI profile

After you install the New Relic CLI, it's time to create your first profile. Profiles contain credentials and settings that you can apply to any CLI command, which is useful when switching between accounts.

Run the [`profiles add`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_profile_add.md) command:

````sh lineNumbers=false
# Create the tutorial account for the US region (default)
newrelic profiles add --profile tutorial --apiKey YOUR_NEW_RELIC_USER_KEY -r YOUR_REGION
# Set the profile as defaults
newrelic profiles default --profile tutorial
```

<Callout variant="important">
  You must set the [region](/docs/accounts/accounts-billing/account-setup/choose-your-data-center) of your New Relic account. Use `-r` to set `us`, `eu`, or `jp`.
</Callout>

````

## Get your application details

Now, add tags to the application you've instrumented with New Relic. [Tags](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/tagging-use-tags-organize-group-what-you-monitor) are key-value pairs that can help you organize and filter your entities. An [entity](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/what-entity-new-relic) (for example, an application) can have a maximum of 100 key-value pairs tied to it.

Before searching for your application using the New Relic CLI, write down or copy your [Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) and the [name of your application in New Relic](https://docs.newrelic.com/docs/agents/manage-apm-agents/app-naming/name-your-application) - you need both to find applications in the New Relic platform.

## Retrieve your application details as a JSON object

To search for your APM application, use the [`apm application search`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_apm_application_search.md) command:

````bash lineNumbers=false
newrelic apm application search --accountId YOUR_ACCOUNT_ID --name NAME_OF_YOUR_APP
```

<Callout variant="tip">
  If you get an error, check that your account ID and application name are correct.
</Callout>

````

## Find the `guid` value

If the account ID is valid, and the application name exists in your account, `apm application search` yields data similar to this example:

````json lineNumbers=false
[
  {
    "accountId": YOUR_ACCOUNT_ID,
    "applicationId": YOUR_APP_ID,
    "domain": "APM",
    "entityType": "APM_APPLICATION_ENTITY",
    "guid": "A_LONG_GUID",
    "name": "NAME_OF_YOUR_APP",
    "permalink": "https://one.newrelic.com/redirect/entity/A_LONG_GUID",
    "reporting": true,
    "type": "APPLICATION"
  }
]
```

When you've successfully searched for your application, look for the `guid` value. It's a unique identifier for your application. You should copy it or write it down.

````

## Add a simple tag to your application

Now that you have the GUID, you can point the New Relic CLI directly at your application. Adding a tag is the simplest way to try out the CLI capabilities (don't worry, tags can be deleted by using [`entity tags delete`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_delete.md)).

Here, you add an environment tag to your application. Add the `dev:testing` tag⁠ (or any other key-value pair) to your application using the [`entities tags create`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_create.md) command:

````sh lineNumbers=false
newrelic entity tags create --guid YOUR_APP_GUID --tag devkit:testing
```

````

## Add tag sets

What if you want to add multiple tags? Tag sets to the rescue! While tags are key-value pairs separated by colons, tag sets are comma separated lists of tags. For example:

````txt copyable=false
tag1:value1,tag2:value2
```

To add multiple tags to your application at once, modify and run this snippet:

```sh lineNumbers=false
newrelic entity tags create --guid YOUR_APP_GUID --tag tag1:test,tag2:test
```

<Callout variant="important">
  Adding tags is an asynchronous operation: this means it could take a while for the tags to get created.
</Callout>

````

## Retrieve your application's tags

You've created and added some tags to your application, but to test that they're working, you need to retrieve them.

Run the [`entity tags get`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_get.md) command:

````sh
newrelic entity tags get --guid YOUR_APP_GUID
```

All tags associated with your application are retrieved as a JSON array:

```json lineNumbers=false
[
  {
    "Key": "tag1",
    "Values": ["true"]
  },
  {
    "Key": "tag2",
    "Values": ["test"]
  },
  {
    "Key": "tag3",
    "Values": ["testing"]
  }
  // ...
]
```

````

## Bonus step: Create a deployment marker

Deployments of applications often go wrong. [Deployment markers](https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/record-monitor-deployments) are labels that, when attached to your application data, help you track deployments and troubleshoot what happened.

To create a deployment marker, run the [`apm deployment create`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_apm_deployment_create.md) command using the same application ID from your earlier search:

````bash lineNumbers=false
newrelic apm deployment create --applicationId YOUR_APP_ID --revision $(git describe --tags --always)
```

````

## Check the JSON response for the revision and timestamp of the deployment

You can build this workflow into a continuous integration or continuous deployment (CI/CD) system to indicate changes in your application's behavior after deployments.

Here's an example:

````json lineNumbers=false
{
  "id": 37075986,
  "links": {
    "application": 204261368
  },
  "revision": "v1.2.4",
  "timestamp": "2020-03-04T15:11:44-08:00",
  "user": "Developer Toolkit Test Account"
}
```

````

## Next steps

Have a look at [all the available commands](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic.md) in the New Relic CLI. For example, you can create a [New Relic workload](https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/workloads/workloads-overview) using [`workload create`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_workload_create.md)

If you'd like to engage with other community members, visit our [New Relic Explorers Hub](https://support.newrelic.com/s/hubtopic/Topic__c/Default?c__categories=%5B%7B%22icon%22%3A%22standard%3Adefault%22%2C%22id%22%3A%22a6c8W000000EeszQAC%22%2C%22sObjectType%22%3A%22Category__c%22%2C%22title%22%3A%22Build%20on%20New%20Relic%22%2C%22titleFormatted%22%3A%22Build%20on%20New%20Relic%22%7D%5D) page. We welcome feature requests or bug reports on [GitHub](https://github.com/newrelic/newrelic-cli).
