---
title: Attach a Nerdlet to an entity
source: https://docs.newrelic.com/docs/new-relic-solutions/tutorials/attach-nerdlet-entity
---

One way for users to access your Nerdlet is by creating a launcher. The launcher opens a Nerdlet from the **Apps** page in New Relic. You can also provide access to your Nerdlet from an [entity](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/what-entity-new-relic/) in your account.

In this guide, you'll learn how to attach your Nerdlet to your entities.

## Before you begin [#begin]

If you haven't already:

-   [Sign up](https://newrelic.com/signup/) for a New Relic account
-   [Install and configure the New Relic One CLI](https://one.newrelic.com/launcher/developer-center.launcher?pane=eyJuZXJkbGV0SWQiOiJkZXZlbG9wZXItY2VudGVyLmRldmVsb3Blci1jZW50ZXIifQ==)

## Create a Nerdpack [#create-nerdpack]

1.  Update your CLI:
    ````sh
    nr1 update
    ```

    ````
2.  Create a Nerdpack with the CLI:
    ````sh
    nr1 create --type nerdpack --name entity-nerdlet
    ```

    This results in a Nerdpack, called `entity-nerdlet`, which consists of a launcher, called `entity-nerdlet-launcher`, and a Nerdlet, called `entity-nerdlet-nerdlet`.

    ````
3.  Serve your Nerdpack:
    ````sh
    cd entity-nerdlet
    nr1 nerdpack:serve
    ```

    ````
4.  Go to <https://one.newrelic.com/?nerdpacks=local>, and navigate to **Apps**.
    `?nerdpacks=local` is required to enable your locally served Nerdpacks to load in New Relic.
5.  Under **Your apps**, click your launcher to view your New Relic application.

## Attach your Nerdlet to entities [#attach-nerdlet]

You've seen how you can access your Nerdlet from a launcher. Now, access your Nerdlet from your entities.

1.  From inside your Nerdpack's root directory, open `nerdlets/entity-nerdlet-nerdlet/nr1.json`. This is your Nerdlet's metadata file. You'll use this file to attach your Nerdlet to entities.
2.  Add a `context` object with an `entities` array:
    ````json fileName=nerdlets/entity-nerdlet-nerdlet/nr1.json
    {
        "schemaType": "NERDLET",
        "id": "entity-nerdlet-nerdlet",
        "displayName": "EntityNerdletNerdlet",
        "description": "",
        "context": {
            "entities": [
            ]
        }
    }
    ```

    This tells New Relic that you want to surface your Nerdlet in an array of entity contexts.

    ````
3.  Add an entity context:
    ````json fileName=nerdlets/entity-nerdlet-nerdlet/nr1.json
    {
        "schemaType": "NERDLET",
        "id": "entity-nerdlet-nerdlet",
        "displayName": "EntityNerdletNerdlet",
        "description": "",
        "context": {
            "entities": [
                {
                    "domain": "APM",
                    "type": "APPLICATION"
                }
            ]
        }
    }
    ```

    Here, you've attached your Nerdlet to all _application_ entities in the _APM_ domain.

    ````
4.  Go to **APM**.
    Because you're serving your Nerdpack locally, remember that you must still specify the `?nerdpacks=local` query string.
5.  Choose any of your applications.
6.  Scroll down to see your Nerdlet attached to the application.
    Click this menu option and see your Nerdlet the same way you did with the launcher.

## Configure your `entities` context [#configure-entity]

The `context.entities` key in your Nerdlet's `nr1.json` file specifies which entities your Nerdlet should be attached to.

### Specify an entity `domain` [#entity-domain]

Attach your Nerdlet to a certain entity domain by specifying the `domain` as one of the following values:

-   `APM`: [Application Performance Monitoring](https://docs.newrelic.com/docs/apm/new-relic-apm/getting-started/introduction-apm/)
-   `BROWSER`: [Browser](https://docs.newrelic.com/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring/)
-   `INFRA`: [Infrastructure monitoring](https://docs.newrelic.com/docs/infrastructure/infrastructure-monitoring/get-started/get-started-infrastructure-monitoring/)
-   `MOBILE`: [Mobile monitoring](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/get-started/introduction-mobile-monitoring/)
-   `SYNTH`: [Synthetic monitoring](https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/getting-started/get-started-synthetic-monitoring/)

For example, attach your Nerdlet to all entities in the `APM` domain:

```json
{
    "context": {
        "entities": [
            {"domain": "APM"}
        ]
    }
}
```

Attach your Nerdlet to all entities _except_ those in a domain:

```json
{
    "context": {
        "entities": [
            {"domain": "!APM"}
        ]
    }
}
```

Attach your Nerdlet to all entities in multiple domains:

```json
{
    "context": {
        "entities": [
            {"domain": "APM"},
            {"domain": "BROWSER"}
        ]
    }
}
```

### Specify an entity `type` [#entity-type]

Attach your Nerdlet to a certain entity type by specifying the `type` as one of the following values:

-   `APPLICATION`
-   `HOST`
-   `MONITOR`

For example, attach your Nerdlet to all entities of the `APPLICATION` type:

```json
{
    "context": {
        "entities": [
            {"type": "APPLICATION"}
        ]
    }
}
```

Attach your Nerdlet to all entities _except_ those of a specified type:

```json
{
    "context": {
        "entities": [
            {"type": "!APPLICATION"}
        ]
    }
}
```

Attach your Nerdlet to every entity whose type matches one of an array of types:

```json
{
    "context": {
        "entities": [
            {"type": "APPLICATION"},
            {"type": "MONITOR"}
        ]
    }
}
```

### Specify entity `tags` [#entity-tags]

Attach your Nerdlet to entities that have a given [tag](https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/core-concepts/use-tags-help-organize-find-your-data/).

For example, attach your Nerdlet to the entity which has a particular GUID:

```json
{
    "context": {
        "entities": [
            {
                "tags": [
                    {
                        "key": "guid",
                        "values": [
                            "<SOME ENTITY GUID>"
                        ]
                    }
                ]
            }
        ]
    }
}
```

Attach your Nerdlet to every entity which has particular `accountId` _and_ uses the Python programming language:

```json
{
    "context": {
        "entities": [
            {
                "tags": [
                    {
                        "key": "accountId",
                        "values": [
                            "<SOME ACCOUNT ID>"
                        ]
                    },
                    {
                        "key": "language",
                        "values": [
                            "python"
                        ]
                    }
                ]
            }
        ]
    }
}
```

### Combine filters [#combine-filters]

When you filter the entities to which your Nerdlet will be added, you can combine `domain`, `type`, and `tags`:

```json
{
    "context": {
        "entities": [
            {
                "domain": "APM",
                "type": "APPLICATION",
                "tags": [
                    {
                        "key": "language",
                        "values": [
                            "python"
                        ]
                    }
                ]
            },
            {
                "domain": "SYNTH",
                "type": "MONITOR"
            },
            {
                "domain": "BROWSER"
            }
        ]
    }
}
```

In this example, you've attached your Nerdlet to:

-   All APM applications whose metadata tags specify the `python` language
-   **AND** all Synthetic monitors
-   **AND** all Browser entities
