---
title: Use tags to help organize and find your data
source: https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/core-concepts/use-tags-help-organize-find-your-data
---

Tags are key-value pairs, for example `team: operations`, added to your monitored entities, or to your dashboards or workloads. We make some important [attributes](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/glossary#attribute) available as tags: this includes app metadata, like the app name and the language, and host metadata like the host name and the cloud provider region. You can also add your own custom tags.

You can use tags in the UI to filter down to relevant entities. Here's an example:

![New Relic filtering workloads using tags](https://docs.newrelic.com/images/workloads_screenshot-full_new-relic-tags.webp "New Relic filtering workloads using tags")

Here you can see an `accountId` tag being used to filter [workloads]((/docs/new-relic-solutions/new-relic-one/workloads/workloads-isolate-resolve-alert-events-faster)) to a specific account.

## The benefits of tags [#benefits]

Tags help you:

-   Organize data coming from a large number of sources and/or to a large number of New Relic accounts.
-   Identify teams, roles, environments, or regions to know who's responsible for what. See [some examples](#org-examples).
-   Better organize and search dashboards and [workloads]((/docs/new-relic-solutions/new-relic-one/workloads/workloads-isolate-resolve-alert-events-faster)).
-   [Query and chart APM data](#query-apm-tags).

Tags are useful for organizing your data at a high level. If you want to add more fine-grained detail, like capturing user names or other high-cardinality values, we recommend using [custom attributes](https://docs.newrelic.com/docs/using-new-relic/data/customize-data/collect-custom-attributes) or [custom events](https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/report-custom-event-data).

## Automatically reported tags [#automated-tags]

Tags are automatically applied to your monitored entities in some cases, from the following sources:

-   New Relic account metadata
-   Agent configuration
-   Host/environment
-   OpenTelemetry resource attributes

Tags from these sources can be removed or changed only by modifying the source of the tag, not via the UI or API.

You can also programmatically automate tags using our [API](https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-tagging-api-tutorial/), the [New Relic CLI](https://developer.newrelic.com/automate-workflows/5-mins-tag-resources), or the [New Relic Terraform provider](https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/entity_tags).

**Account-related tags**

We automatically apply certain tags to entities that include account information. These tags include:

-   `account`
-   `accountId`

**Agent config tags**

New Relic agents can be configured to apply tags to the entities created from their data. [Configuration options](https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/configure-new-relic-agents) are somewhat agent-specific, but generally use the `labels` key. Some examples:

-   [Java agent tag config](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#labels)
-   [.NET agent tag config](https://docs.newrelic.com/docs/apm/agents/net-agent/configuration/net-agent-configuration/#labels-tags)

    Tags applied from APM agent configuration can result in multiple values for a given tag key on a given entity, because each deployed instance of the agent could be configured to send a different value.

**Host/environment tags**

New Relic agents automatically apply certain tags to service entities based on the environment. These include (but are not limited to):

-   For service/application entities
    -   `language`: (for example, `java` or `python`)
-   For host entities

    -   `awsRegion`, when applicable

    If you're using one of our [cloud provider integrations](https://docs.newrelic.com/docs/infrastructure/infrastructure-integrations/get-started/introduction-infrastructure-integrations/#cloud) (AWS, Azure, or Google Cloud Platform), we recommend installing the infrastructure agent on your hosts: this will add cloud environment tags to your monitored host entities in New Relic.

**Enhanced tags for on-host database integrations:** For certain on-host integrations, including MySQL, Microsoft SQL Server, and PostgreSQL, additional rich tags are automatically generated from your integration configuration files (for example, `mysql-config.yml`, `mssql-config.yml`) and infrastructure agent custom attributes (`newrelic-infra.yml` with a `label.` prefix). This provides deeper, automated context for your database entities. [Learn more about enhanced tags for database entities.](https://docs.newrelic.com/docs/infrastructure/host-integrations/db-entity-tags)

## Manage tags [#tag-management]

Some important [attributes](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/glossary#attribute) are available by default to be used as tags. For example, the account name, the account ID, and some basic host and server metadata. You can't remove these available-by-default tags.

When you add tags via the UI or API, this occurs at the entity level. This means that, for example, if you have multiple APM agents monitoring a single entity and apply a tag via the UI, that tag is available for all data coming from that entity.

To change a tag name, you'll need to delete the current tag and create a new tag with the desired name.

### Add tags [#add-tags]

1.  Go to **[one.newrelic.com](https://one.newrelic.com/all-capabilities)** and select a monitored entity, like a monitored app or host.

2.  Near the entity's name at the top of the page, click on the **tags** button.

3.  In the **Add a new tag...** field of the tags widget, add a tag with this format: `accountId: 123456789`.
    ![Add tags in New Relic](https://docs.newrelic.com/images/solutions_screenshot-full_tag-management.webp "Add tags in New Relic")

4.  For APM agents, if you want to use those tags in NRQL queries, restart your service.

### Remove tags [#remove-tags]

1.  Go to **[one.newrelic.com](https://one.newrelic.com/all-capabilities)** and select a monitored entity, like a monitored app or host.
2.  Near the entity's name at the top of the page, click on the **tags** button.
3.  Click the ✗ next to the tag you want to remove.
4.  For APM agents, if you want to use those tags in NRQL queries, restart your service.

**Manage alert condition tags**

1.  Navigate to a condition.
2.  Near the condition's name at the top of the form, click **Manage tags**.
3.  In the menu that pops up, add or delete a tag.

    You can also add tags to an alert condition as an entity via the NerdGraph API (utilize the condition's entity GUID from the 'manage tags' screen).

    See our tutorial to learn more about [tagging data via the NerdGraph API](https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-tagging-api-tutorial).

**Automate tags with our CLI**

For a guide to automating tags using our CLI tool, see [our developer site](https://developer.newrelic.com/automate-workflows/5-mins-tag-resources).

Check out this short video on querying APM tags (3:20 minutes).

[Video](https://www.youtube.com/embed/JImDdncerko)

## Use tags to filter your entities [#filter-tags]

![New Relic advanced tag filter query](https://docs.newrelic.com/images/solutions_screenshot-full_tag-filter-query.webp "New Relic advanced tag filter query")

Use the filter bar on the [entity explorer UI](https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/core-concepts/new-relic-explorer-view-performance-across-apps-services-hosts#find) to filter down to specific entities.

You can filter by single or multiple elements and use advanced search options.

To filter down to certain entities using tags:

1.  Go to **[one.newrelic.com](https://one.newrelic.com/all-capabilities)**.
2.  Click the **Filter by ...** field to see a dropdown of available attributes and tags or enter a tag you want to filter by, such as `accountId: 123456789`.

## Best practices [#best-practices]

Follow these best practices to get the most out of your tags.

**Tag format and limits**

-   The UI has limits on the total number of tags it can display per entity:
    -   Limit of 100 for tags reported by default or added via agent/integration configuration.
    -   Limit of 100 for custom tags added via UI or API.
-   The following are maximum character length for tags:
    -   Key: 128 characters
    -   Value: 256 characters
-   Allowed characters:
    -   Characters must be UTF-8.
    -   When [using NerdGraph to add tags](https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-tagging-api-tutorial), a dash `-` in a tag key is interpreted as a minus symbol. If your tag key has a dash, use back ticks around it, like `` `key-name` ``.

**Keep tags simple**

Some tips on keeping tags simple:

-   Start by adding only tags you know you'll definitely use. Unused tags create noise and may add confusion.
-   Try to use short tags. Shorter tags are easier to parse, and also the UI may sometimes truncate longer tags. (See [character limits](#formatting).)
-   When possible, use keys and values that are human-readable (for example, `region: EMEA` is better than `Param8323 : 1229072`).
-   Avoid including several values like `regions: EMEA | US | LATAM` in a single tag. We recommend using three different tags for that, like `region: emea`, `region: us`, and `region: latam`. If you want to match multiple tags, you can do that using the advanced options in the filter UI.
    -   A caveat for [alert events](https://docs.newrelic.com/docs/alerts-applied-intelligence/overview/#concepts-terms): these only support one key name instance. If you do use multiple key names, one will be randomly selected to be added to that issue.

**Use consistent tags**

-   Try to be consistent with tag language across your teams and entities.
-   Be consistent with naming. For example, avoid using both `region: emea` and `reg: emea`.
-   Be consistent with format. For example, avoid using both `camelCase` and `kebab-case`.
-   Although tag searching is not case-sensitive in the UI and API, try to be consistent with capitalization. For example, avoid using both `env: staging` and `env: Staging`.

**Use cross-team tags**

Tags help improve observability and cost allocation. For this reason, responsibility for tag implementation is often assigned to an observability team, SREs, a group of architects, or a cross-team task force.

We recommend the people responsible for implementing tags meet and create an internal policy to describe how the tags are defined and which conventions are to be used. Then:

-   Keep this reference manual up to date.
-   Automate the definition of tags when you deploy New Relic agents, at the cloud provider, or through New Relic automation tools, such as the [API](https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-tagging-api-tutorial) or the [New Relic Terraform provider](https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/entity_tags).
-   Create recurring reports that identify entities that are non-compliant with your tagging standards.

## Tag examples [#org-examples]

Here are some examples of common ways to use tags to organize data.

**Team-related tags**

Creating tags for team names can be helpful to understand which team, group, department, or region was responsible for a change that led to a performance issue.

````
### Team tags
team: backend
team: frontend
team: db
### Role tags
roles: architecture
roles: devops
roles: pm
### Region tags
region: emea
region: america
region: asia
```

````

**Environment-related tags**

You can create entities for the environment they belong to. For example:

````
env: production
env: qa
env: development
env: staging
```

````

**Criticality-related tags**

You can create tags related to criticality levels, which lets you easier track the most critical issues. For example:

````
layer: level1
layer: level2
layer: level3
```

````

## Custom queries, dashboards, and alerts [#query-tags]

Different features handle tags differently. Here are some details about how you can use [NRQL](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/introduction-nrql-new-relics-query-language/) to query tag data, or create [NRQL condition alerts](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/alert-conditions/create-nrql-alert-conditions).

Learn about [how to use tags with dashboards](https://docs.newrelic.com/docs/query-your-data/explore-query-data/dashboards/introduction-dashboards#filter-dashboards) and [how to use tags with workloads](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/workloads/use-workloads).

### Query and alert on APM tags [#query-apm-tags]

You can query APM tags using NRQL. These are the supported [APM agents](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/update-new-relic-agent):

-   Go v2.3.0 or higher
-   Java v4.9.0 or higher
-   .NET v8.17 or higher
-   Node.js v4.13.0 or higher
-   PHP v10.0.0.312 or higher
-   Python v4.10.0.112 or higher
-   Ruby v6.1.0.352 or higher

### Query and alert on infrastructure tags [#query-infra-tags]

You can query infrastructure tags with NRQL, also known as tag propagation, if they're created:

-   As custom attributes: By adding a section in your `newrelic-infra.yml` configuration file, such as:

    ```yml
    custom_attributes:
      internalOwningTeam: devops-sf
      service: api-platform
    ```

    > #### 💡 TIP
    >
    > For more information, read about [custom attributes](https://docs.newrelic.com/docs/data-apis/custom-data/custom-events/collect-custom-attributes).

-   In the New Relic UI: On the entity's infrastructure page, create a tag and assign it a value. To query these tags, you need to add the `tags.` prefix to the name of the tag when you're quering for it in NRQL.

If you want to turn off infrastructure tag propagation, which means that you won't be able to query them with NRQL, see [how to turn it off with Nerdgraph](#propagation-off).

### Query examples [#query-examples]

**Throughput across shards**

Given a service that is distributed across nine shards, each shard assigned as an `environment`, we can plot the transaction throughput on all shards using a [wildcard](https://docs.newrelic.com/docs/telemetry-data-platform/understand-data/metric-data/query-metric-data-type/#query-multiple-metrics-wildcards) query like:

````sql
SELECT rate(count(apm.service.transaction.duration), 1 minute)
FROM Metric WHERE appName LIKE 'MyApp (%' AND transactionType = 'Other'
FACET tags.Environment TIMESERIES
```

````

**Transactions per team**

To see the number of transactions per service for a specific team, we might use a query like:

````sql
FROM Transaction SELECT count(*)
WHERE tags.Team = 'team-a'
FACET tags.Project TIMESERIES
```

````

**Alert on error rate for teams**

You can use a query for your services' error rate for setting an alert without having to create a rule for each service. Here is the error rate for all services on a team called `team-b`. And this alert will automatically monitor any new app names added with the team tag.

````sql
FROM Metric SELECT count(apm.service.error.count) / count(apm.service.transaction.duration)
WHERE tags.Team = 'team-b' FACET appName
```

Related to this, you might create a general rule for a specific service deployed across several environments, so that we have an alarm for a single service monitoring each environment individually:

```sql
FROM Metric SELECT count(apm.service.error.count) / count(apm.service.transaction.duration)
WHERE tags.Project = 'MyProject' FACET tags.Environment
```

````

**Find internal teams that own specific entities for infrastructure monitoring**

To find internal teams that own entities named, for example, `SensitiveEntity`, run the following:

````sql
FROM SystemSample SELECT internalOwningTeam WHERE entityName = 'SensitiveEntity'
```

````

**Compare groups in a CPU load test experiment**

Let's say you want to do some load testing on your different infrastructure entities with CPUs. You can apply one treatment to entities in a group called `A`, apply a different treatment to entities in a group called `B`, and keep one group of entities with no treatments, called `control group`.

You can create tags called `experimentGroup` in the New Relic UI, mapped to the experimental group that each entity belongs to. Since these are tags created in the New Relic UI, you need to add the `tags.` prefix to the tag name, unlike with custom attributes created in the `newrelic-infra.yml` configuration file.

Here's the NRQL query to select `cpuPercent`, broken down by the different experimental groups using a `FACET CASES (...)` clause:

````sql
FROM SystemSample SELECT cpuPercent 
FACET CASES 
(
  WHERE tags.experimentGroup = 'control' AS 'control group', 
  WHERE tags.experimentGroup = 'A' AS 'given treatment A', 
  WHERE tags.experimentGroup = 'B' AS 'given treatment B'
) 
SINCE 1 DAY AGO
```

````

**Turn off tag propagation for infrastructure tags**

To turn off tag propagation for infrastructure tags, run the following in [NerdGraph](https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph):

````graphql
mutation {
  dataManagementUpdateFeatureSettings(
    accountId: YOUR_ACCOUNT_ID
    setting: {
      enabled: false
      featureSetting: { key: "infra_tag_propagation" }
      locked: false
    }
  ) {
    enabled
    key
    locked
    name
  }
}
```

That call should return the following answer:

```graphql
{
  "data": {
    "dataManagementUpdateFeatureSettings": {
      "enabled": false,
      "key": "infra_tag_propagation",
      "locked": false,
      "name": "Infra tag propagation"
    }
  }
}
```

````

### Query and alert on attributes [#query-alert-attributes]

Some important [attributes](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/glossary#attribute) are used as tags. You can query all attributes and create custom charts using [NRQL](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/introduction-nrql-new-relics-query-language), and create [NRQL alert conditions](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/alert-conditions/create-nrql-alert-conditions).
