List labels (v2)

To use these examples list the labels available in your account, replace ${API_KEY}with the REST API key associated with the account. You can also use the New Relic REST API Explorer (v2) to list label values.

List existing labels

To list the labels that exist in your account, use this command:

curl 'https://api.newrelic.com/v2/labels.json' \
     -H "X-Api-Key:${API_KEY}" -i 

View the output

The output for the label includes:

  • The full key name for the label (for example, Staging:Test1), as well as the component and name for the key
  • The application health_status (red, orange, green, gray) and application IDs for the label in each category
  • Apps that have this label; for example, the label Staging:Test1 has been applied to one application (4937390) and two hosts (3801143 and 5879721)

The output for a label listing will appear similar to this:

{
  "labels": [
    {
      "key": "Production:Main",
      "category": "Production",
      "name": "Main",
      "application_health_status": {
        "green": [],
        "orange": [],
        "red": [],
        "gray": []
      },
      "links": {
        "applications": [],
      }
    },
    {
      "key": "Staging:Test1",
      "category": "Staging",
      "name": "Test1",
      "application_health_status": {
        "green": [],
        "orange": [],
        "red": [
          4937390
        ],
        "gray": []
      },
      "links": {
        "applications": [
          4937390
        ],
      }
    },
...
}

For more help

Recommendations for learning more: