• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Manage entities in alerts conditions

In , an entity is defined as any target for monitoring, such as an application, a browser, or a host. The alerts UI shows available entities that you can select. You can also use the REST API and API Explorer to add or remove entities for a condition.

Before using the REST API

The REST API is no longer the preferred way to programmatically manage your alerts. For more context, read the Intro to APIs for alerts.

Requirements

Modifying the list of entities in a condition requires you to know:

General procedure

To update the entity list for a condition:

  1. Locate the appropriate entity ID; for example, Application ID and browser ID.
  2. Identify the policy ID by name or type.
  3. Get the list of conditions associated with the policy and choose the one you want to modify for the appropriate category:
  4. Modify the condition using the add or remove API requests.

Important

Follow the requirements for the minimum and maximum number of entities you can add to conditions.

Example: Add or remove an entity

The following example shows how to add a Ruby application named TimberTime in a condition and how to remove an entity from that same condition.

Only the first step in this example is unique to choosing the Ruby app as the entity. The remaining steps will be the same for whichever entity you choose.

  1. Get the entity_id; for example, application_id:

    bash
    $
    curl -X GET 'https://api.newrelic.com/v2/applications.json' \
    >
    -H $API_KEY -i

    OR

    If you know the application name, use this command and specify the app_name:

    bash
    $
    curl -X GET 'https://api.newrelic.com/v2/applications.json' \
    >
    -H $API_KEY -i \
    >
    -d 'filter[name]=TimberTime'
  2. Review the output to find the application_id, and use it as the entity_id:

    {
    "applications": [
    {
    "id": 12345, // application_id == entity_id
    "name": "TimberTime",
    "language": "ruby",
    "health_status": "gray",
    ...
    },
  3. Get the policy_id you want to update; for example, the TimberTime app's Logjam Alert policy. To get the policy_id, use this command:

bash
$
curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
>
-H $API_KEY -i \
>
-G -d 'filter[name]= Logjam Alert' # policy_name
  1. Review the policy output; for example:

    {
    "policies": [
    {
    "id": 85, // policy_id
    "incident_preference": "PER_POLICY",
    "name": "Logjam Alert",
    "created_at": 1461176510393,
    "updated_at": 1461176510393
    },
  2. List all of this policy's conditions and locate the condition_id:

bash
$
curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \
>
-H $API_KEY -i \
>
-G -d 'policy_id=85'

Review the policy conditions; for example:

{
"conditions": [
{
"id": 234567, // condition_id
"type": "apm_app_metric",
"name": "Throughput (web) (High)",
"enabled": true,
"entities": [
"8288171" // Entity currently included in the policy
],
"metric": "response_time_web",
"terms": [
{
"duration": "5",
"operator": "above",
"priority": "critical",
"threshold": "500",
"time_function": "all"
}
]
}
]
}
  1. Use API requests to add entities to or remove entities from the policy's condition:

    To add entity_id 12345 to condition_id 234567, with entity_type set as Application:

    bash
    $
    curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/12345.json' \
    >
    -H $API_KEY -i \
    >
    -H 'Content-Type: application/json' \
    >
    -G -d 'entity_type=Application&condition_id=234567'

    To remove entity_id 8288171 from condition_id 234567, with entity_type set as Application:

bash
$
curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/8288171.json' \
>
-H $API_KEY -i \
>
-G -d 'entity_type=Application&condition_id=234567'
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.