New Relic's REST API (v2) allows you to configure settings for New Relic Alerts. The API Explorer also includes the cURL request format, available parameters, potential response status codes, and JSON response structure for each of the available API calls. You can also create alert conditions in the New Relic UI.
For New Relic Infrastructure alerting, see REST API for New Relic Infrastructure alerts.
Available data and functions via API
The amount of data available depends on your subscription level and data retention.
Available functions depend on your role in your New Relic account. Some limitations apply.
REST API functions | Comments |
---|---|
View account data |
In general, any role can use the account's REST API key with GET > List functions to view New Relic Alerts data. The account Owner and Admins may use their Admin user's API key. List output will be paginated. Available functions include:
|
Maintain account data | You must have an Owner or Admin role in your account and an Admin user's API key in order to use any maintenance function, including POST > Create, PUT > Add, PUT > Update, and DELETE. |
Conditions excluded from the REST API
These types of conditions do not have available endpoints in the API:
- APM: Web transaction percentiles, conditions targeting labels, and baselines
- NRQL: Baselines
Alert policies
These API functions include links to the API Explorer, where you can create, delete, or list policies for New Relic Alerts.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- Create new policies
-
To add new policies to New Relic Alerts, use your Admin user's API key, and include these two values in the API call:
Required values Definition Incident incident_preference
Determines how New Relic Alerts will create incidents and group violations. This must be one of the following:
PER_POLICY
(default): Roll up by policy.PER_CONDITION
: Roll up by condition.PER_CONDITION_AND_TARGET
: Roll up by target and condition.
Policy name
The policy name
is required. Leaving it unchanged will create a policy called string.API Explorer: Alerts Policies > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_policies.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "policy": { "incident_preference": "string", "name": "string" } }'
- Update policies
-
Use this API to update an existing policy's
name
andincident_preference
. You will need your Admin user's API key.Required values Definition id
Required. To find a policy's ID, use either of these options: -
From the UI: On an alert policy's UI page, the second number in the URL will represent the policy ID. For example, for the URL
alerts.newrelic.com/accounts/654321/policies/123456
, the policy ID is123456
. - With the API: Use the List policies API.
Incident incident_preference
Determines how New Relic Alerts will create incidents and group violations. Must be one of the following:
PER_POLICY
(default): Roll up by policy.PER_CONDITION
: Roll up by condition.PER_CONDITION_AND_TARGET
: Roll up by target and condition.
Policy name
Required. If you do not change the name, it defaults to a policy called string.
To find a policy's exact name, use the List policies API.
API Explorer: Alerts Policies > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_policies/{id}.json' \ -H 'X-Api-Key:{api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "policy": { "incident_preference": "string", "name": "string" } }'
-
- Delete existing policies
-
To delete an existing policy from New Relic Alerts, use your Admin user's API key, and include the
policy_id
(available from API Explorer: Alerts Policies > GET > List) in the API call:API Explorer: Alerts Policies > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- List existing policies
-
To view a list of existing New Relic Alerts policies for your account, use your API key, and include these optional values in the API call:
- Optional policy
name
filter - Optional pagination value
API Explorer: Alerts Policies > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \ -H 'X-Api-Key:{api_key}' -i
- Optional policy
Notification channels
These API functions include links to the API Explorer, where you can create, delete, or list notification channels for your alert policies in New Relic Alerts.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- Create new notification channels
-
To add new notification channels to New Relic Alerts, use your Admin user's API key and include these values in the API call:
- New channel's name
- Type of channel
- Configuration values
The API Explorer shows the format for required configuration values for each type of notification channel.
API Explorer: Alerts Channels > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_channels.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "channel": { "name": "string", "type": "string", "configuration": "hash" } }'
The
"hash"
place holder in this example must be replaced by one of the following JSON blocks with the appropriate values substituted:- Email channel
-
{ "recipients" : "test@google.com", "include_json_attachment" : true }
- OpsGenie channel
-
{ "api_key": "abc123", "teams": "team1", "tags": "tag1", "recipients": "me@me.com" }
- Slack channel
-
{ "url": "http://test.com", "channel": "channel1" }
- VictorOps channel
-
{ "key": "mykey", "route_key": "theroute" }
- PagerDuty channel
-
{ "service_key": "myservicekey" }
- Webhook (json) channel
-
This example shows the default
payload
inserted. (Thepayload
attribute is optional.)The
payload
can be customized to have different keys than the ones shown and will be sent with the$
prefixed attributes interpolated prior to delivery.The
condition_id
is deprecated. Instead, usecondition_family_id
.{ "base_url": "http://test.com", "auth_username": "username", "auth_password": "password", "payload_type": "application/json", "headers": { "header1": "test", "header2": "test" } "payload": { "account_id": "$ACCOUNT_ID", "account_name": "$ACCOUNT_NAME", "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL", "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING", "condition_family_id": "$CONDITION_FAMILY_ID", "condition_id": "$CONDITION_ID", "condition_name": "$CONDITION_NAME", "current_state": "$EVENT_STATE", "details": "$EVENT_DETAILS", "duration": "$DURATION", "event_type": "$EVENT_TYPE", "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL", "incident_id": "$INCIDENT_ID", "incident_url": "$INCIDENT_URL", "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL", "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING", "owner": "$EVENT_OWNER", "policy_name": "$POLICY_NAME", "policy_url": "$POLICY_URL", "runbook_url": "$RUNBOOK_URL", "severity": "$SEVERITY", "targets": "$TARGETS", "timestamp": "$TIMESTAMP", "violation_callback_url": "$VIOLATION_CALLBACK_URL", "violation_chart_url": "$VIOLATION_CHART_URL" } }
- Webhook (x-www-form-urlencoded) channel
-
This example shows the default
payload
inserted. (Thepayload
attribute is optional.)The
payload
can be customized to have different keys than the ones shown and will be sent with the$
prefixed attributes interpolated prior to delivery.The
condition_id
is deprecated. Instead, usecondition_family_id
.{ "base_url": "http://test.com", "auth_username": "username", "auth_password": "password", "payload_type": "application/x-www-form-urlencoded", "headers": { "header1": "test", "header2": "test" }, "payload": { "account_id": "$ACCOUNT_ID", "account_name": "$ACCOUNT_NAME", "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL", "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING", "condition_family_id": "$CONDITION_FAMILY_ID", "condition_id": "$CONDITION_ID", "condition_name": "$CONDITION_NAME", "current_state": "$EVENT_STATE", "details": "$EVENT_DETAILS", "duration": "$DURATION", "event_type": "$EVENT_TYPE", "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL", "incident_id": "$INCIDENT_ID", "incident_url": "$INCIDENT_URL", "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL", "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING", "owner": "$EVENT_OWNER", "policy_name": "$POLICY_NAME", "policy_url": "$POLICY_URL", "runbook_url": "$RUNBOOK_URL", "severity": "$SEVERITY", "targets": "$TARGETS", "timestamp": "$TIMESTAMP", "violation_callback_url": "$VIOLATION_CALLBACK_URL", "violation_chart_url": "$VIOLATION_CHART_URL" } }
- Delete existing notification channels
-
To delete an existing notification channels, use your Admin user's API key, and include the
channel_id
(available from API Explorer: Alerts Channels > GET > List) in the API call:API Explorer: Alerts Channels > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_channels/{channel_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- List existing notification channels
-
To view a list of existing notification channels for your account, use your REST API key or Admin user's API key and an optional pagination value in the API call.
API Explorer: Alerts Channels > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_channels.json' \ -H 'X-Api-Key:{api_key}' -i
- Update notification channels associated with policies
-
You can associate a policy with one or more notification channels. You can also associate a notification channel with one or more alert policies. To add notification channels to policies, use your Admin user's API key and these values in the API call:
- A
policy_id
value (available from API Explorer: Alerts Policies > GET > List) - One or more
channel_id
values in an array, separated by commas or a new line (available from API Explorer: Alerts Channels > GET > List)
API Explorer: Alerts Policy Channels > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_policy_channels.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -G -d 'policy_id=policy_id&channel_ids=channel_id'
- A
- Delete notification channels associated with policies
-
You can associate a policy with one or more notification channels. You can also associate a notification channel with one or more alert policies.
To remove a policy from a channel, or to remove a channel from a policy, use your Admin user's API key and these values in the API call:
- The
policy_id
(available from API Explorer: Alerts Policies > GET > List) - The
channel_id
(available from API Explorer: Alerts Channels > GET > List)
API Explorer: Alerts Policy Channels > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_policy_channels.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -d 'channel_id={channel_id}&policy_id={policy_id}'
- The
Conditions for APM, Browser, Mobile
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. These calls are for conditions with these types of entities:
- APM: Apps and key transactions
- Browser: Apps and key transactions
- Mobile: Mobile apps
Exception: The following APM conditions are not available from this API endpoint:
- Conditions targeting labels (dynamic targeting)
- Web transaction percentile conditions
- Baseline conditions
The API Explorer provides information about other types of conditions using separate endpoints, including external services (APM and Mobile), plugins, and Synthetics monitors. Consider all types of alert conditions when searching or updating. If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- Create conditions for policies
-
To add conditions to policies, include these values in the API call:
- Your Admin user's API key
- The
policy_id
(available from API Explorer: Alerts Policies > GET > List) - The required
condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts Conditions > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_conditions/policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "condition": { "type": "string", "name": "string", "enabled": boolean, "entities": [ integer ], "metric": "string", "gc_metric": "string", "condition_scope": "string", "violation_close_timer": integer, "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "user_defined": { "metric": "string", "value_function": "string" } } }'
The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer: Alerts Conditions > GET > List. - Update conditions for policies
-
To update conditions for policies, include these values in the API call:
- Your Admin user's API key
- The condition's
id
(available from API Explorer: Alerts Conditions > GET > List) - The required
condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts Conditions > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/{id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "condition": { "type": "string", "name": "string", "enabled": boolean, "entities": [ integer ], "metric": "string", "metric": "string", "gc_metric": "string", "condition_scope": "string", "violation_close_timer": integer, "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "user_defined": { "metric": "string", "value_function": "string" } } }'
- Delete conditions from policies
-
To delete conditions from policies, include these values in the API call:
- Your Admin user's API key
- The
condition_id
(available from API Explorer: Alerts Conditions > GET > List)
API Explorer: Alerts Conditions > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_conditions/{condition_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- List existing conditions for policies
-
To view a list of existing conditions for your alert policy, use your REST API key or Admin user's API key and the associated
policy_id
in the API call.API Explorer: Alerts Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \ -H 'X-Api-Key:{api_key}' -i \ -d 'policy_id={policy_id}'
Conditions for NRQL (Insights)
These API functions include links to the API Explorer, where you can create, update, delete, or list NRQL conditions for your alert policies.
Exception: NRQL baseline conditions are not available from this endpoint.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- Create NRQL conditions for policies
-
Recommendation: Due to the way NRQL data is aggregated, set the
nrql[since_value]
to3
or higher to prevent false positives.API Explorer: Alerts Nrql Conditions > POST > Create
To create NRQL conditions for policies:
curl -X POST 'https://api.newrelic.com/v2/alerts_nrql_conditions/policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "nrql_condition": { "type": "string", "name": "string", "runbook_url": "string", "enabled": boolean, "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "value_function": "string", "nrql": { "query": "string", "since_value": "string" } } }'
If you set
nrql[since_value]
to3
andnrql[query]
toSELECT count FROM myEvent
, New Relic Alerts evaluates the following query against theterms[threshold]
value once per minute:SELECT count FROM myEvent SINCE 3 minutes ago UNTIL 2 minutes ago
If you set
type
asoutlier
, you can omit thevalue_function
. However, two additional fields are required:expected_groups
andignore_overlap
. For more information, see Alerts conditions API field names.If you omit
type
or set it asstatic
, it will default to standard NRQL alerting. - Update NRQL conditions for policies
-
Recommendation: Due to the way NRQL data is aggregated, set the
nrql[since_value]
to3
or higher to prevent false positives. (This allows three minutes to aggregate data.)To update NRQL conditions for policies, include these values in the API call:
- Your Admin user's API key
- The condition's
id
(available from API Explorer: [external link] Alerts Nrql Conditions > GET > List) - The required
condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts Nrql Conditions > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_nrql_conditions/{id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "nrql_condition": { "name": "string", "runbook_url": "string", "enabled": boolean, "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "value_function": "string", "nrql": { "query": "string", "since_value": "string" } } }'
- Delete NRQL conditions for policies
-
To delete NRQL conditions from policies, include these values in the API call:
- Your Admin user's API key
- The condition's
id
(available from API Explorer: [external link] Alerts Nrql Conditions > GET > List)
API Explorer: Alerts Nrql Conditions > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_nrql_conditions/{condition_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- List existing NRQL conditions for policies
-
To view a list of existing conditions for your alert policy, use your REST API key or Admin user's API key and the associated
policy_id
in the API call.API Explorer: Alerts Nrql Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_nrql_conditions.json' \ -H 'X-Api-Key:{api_key}' -i \ -d 'policy_id={policy_id}'
Conditions for external services
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. These calls are for conditions for external services. The API calls can be used with APM and Mobile apps.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- External services: Create conditions for policies
-
To add conditions for external services to policies that have APM or Mobile apps, include these values in the API call:
- Your Admin user's API key
- The
policy_id
(available from API Explorer: Alerts Policies > GET > List) - The required
external_service_condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts External Service Conditions > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_external_service_conditions/policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "external_service_condition": { "type": "string", "name": "string", "enabled": boolean, "entities": [ integer ], "external_service_url": "string", "metric": "string", "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ] } }'
The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer: Alerts External Service Conditions > GET > List. - External services: Update conditions for policies
-
To update conditions for external services to policies that have APM or Mobile apps, include these values in the API call:
- Your Admin user's API key
- The external service condition's
id
(available from API Explorer: Alerts External Service Conditions > GET > List) - The required
external_service_condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts External Service Conditions > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_external_service_conditions/{id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "external_service_condition": { "type": "string", "name": "string", "enabled": boolean, "entities": [ integer ], "external_service_url": "string", "metric": "string", "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ] } }'
- External services: Delete conditions from policies
-
To delete conditions for external services from policies with APM or Mobile apps, include these values in the API call:
- Your Admin user's API key
- The
condition_id
(available from API Explorer: Alerts External Service Conditions > GET > List)
API Explorer: Alerts External Service Conditions > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_external_service_conditions/{condition_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- External services: List existing conditions for policies
-
To view a list of existing conditions for policies with external service apps (APM or Mobile), use your REST API key or Admin user's API key and the associated
policy_id
in the API call.API Explorer: Alerts External Service Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_external_service_conditions.json' \ -H 'X-Api-Key:{api_key}' -i \ -d 'policy_id={policy_id}'
Conditions for Synthetics
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. The API calls can be used with Synthetics monitors.
- Synthetics: Create conditions for policies
-
To add conditions to policies for Synthetics monitors, include these values in the API call:
- Your Admin user's API key
- The
policy_id
(available from API Explorer: Alerts Policies > GET > List) - The required
synthetics_condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts Synthetics Conditions > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_synthetics_conditions/policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "synthetics_condition": { "name": "string", "monitor_id": "string", "runbook_url": "string", "enabled": boolean } }'
The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer: Alerts Synthetics Conditions > GET > List. - Synthetics: Update conditions for policies
-
To update policy conditions for Synthetics monitors, include these values in the API call:
- Your Admin user's API key
- The condition
id
(available from API Explorer: Alerts Synthetics Conditions > GET > List) - The required
synthetics_condition
values in the API call (described in the API Explorer page to create alert conditions for Synthetics and in the Alerts conditions API glossary)
API Explorer: Alerts Synthetics Conditions > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_synthetics_conditions/{id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "synthetics_condition": { "name": "string", "monitor_id": "string", "runbook_url": "string", "enabled": boolean } }'
- Synthetics: Delete conditions from policies
-
To delete policy conditions for Synthetics monitors, include these values in the API call:
- Your Admin user's API key
- The
condition_id
(available from API Explorer: Alerts Synthetics Conditions > GET > List)
API Explorer: Alerts Synthetics Conditions > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_synthetics_conditions/{condition_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- Synthetics: List existing conditions for policies
-
To view a list of existing policy conditions Synthetics monitors, use your REST API key or Admin user's API key and the associated
policy_id
in the API call.API Explorer: Alerts Synthetics Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_synthetics_conditions.json' \ -H 'X-Api-Key:{api_key}' -i \ -d 'policy_id=policy_id'
Conditions for plugins
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. The API calls can be used with plugins from New Relic's Plugin Central.
- Plugins: Create conditions for policies
-
To add conditions to policies for plugin components or instances, include these values in the API call:
- Your Admin user's API key
- The
policy_id
(available from API Explorer: Alerts Policies > GET > List) - The required
plugins_condition
values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer: Alerts Plugins Conditions > POST > Create
curl -X POST 'https://api.newrelic.com/v2/alerts_plugins_conditions/policies/{policy_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "plugins_condition": { "name": "string", "enabled": boolean, "entities": [ integer ], "metric_description": "string", "metric": "string", "value_function": "string", "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "plugin": { "id": "string", "guid": "string" } } }'
The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer: Alerts Plugins Conditions > GET > List. - Plugins: Update conditions for policies
-
To update policy conditions for plugin components or instances, include these values in the API call:
- Your Admin user's API key
- The condition
id
(available from API Explorer: Alerts Plugins Conditions > GET > List) - The required
plugins_condition
values in the API call (described in the API Explorer page to create alert conditions for plugins and in the Alerts conditions API glossary)
API Explorer: Alerts Plugins Conditions > PUT > Update
curl -X PUT 'https://api.newrelic.com/v2/alerts_plugins_conditions/{id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i \ -H 'Content-Type: application/json' \ -d \ '{ "plugins_condition": { "name": "string", "enabled": boolean, "entities": [ integer ], "metric_description": "string", "metric": "string", "value_function": "string", "runbook_url": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "plugin": { "id": "string", "guid": "string" } } }'
- Plugins: Delete conditions from policies
-
To delete conditions from policies for plugin components or instances, include these values in the API call:
- Your Admin user's API key
- The condition
id
(available from API Explorer: Alerts Plugins Conditions > GET > List)
API Explorer: Alerts Plugins Conditions > DELETE > Delete
curl -X DELETE 'https://api.newrelic.com/v2/alerts_plugins_conditions/{condition_id}.json' \ -H 'X-Api-Key:{admin_api_key}' -i
- Plugins: List existing conditions for policies
-
To view a list of existing conditions for policies with plugin components or instances, use your REST API key or Admin user's API key and the associated
policy_id
in the API call.API Explorer: Alerts Plugins Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_plugins_conditions.json' \ -H 'X-Api-Key:{api_key}' -i \ -d 'policy_id={policy_id}'
Alert activity: Events, violations, incidents
These API functions include links to the API Explorer, where you can view information about events, violations, and incidents for your alert policies.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- Events
-
To view events for entities monitored by New Relic APM, Browser, Mobile, Plugins, Synthetics, and Alerts, include these values in the API call:
- Your REST API key or Admin user's API key
- Other optional values to use as filters (described in the API Explorer page) that depend on the type of product (New Relic Browser, New Relic Mobile, etc.), entity (as apps or key transactions for New Relic APM, monitors for New Relic Synthetics, etc.), and type of event (notification, deployment, instrumentation, etc.)
- An optional pagination value
API Explorer: Alerts Events > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_events.json' \ -H 'X-Api-Key:{api_key}' -i
- Violations
-
To view violations for any entity monitored by New Relic Alerts for your account, include these values in the API call:
- Your REST API key or Admin user's API key
- An optional flag to show only those violations that are currently open
- An optional pagination value
API Explorer: Alerts Violations > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_violations.json' \ -H 'X-Api-Key:{api_key}' -i
To find policy, condition, and incident information: take the IDs found in the
links
section in theviolations
property and place them into the URLs contained in the outerlinks
property of the payload. - Incidents
-
To view incidents for any entity monitored by New Relic Alerts for your account, include these values in the API call:
- Your REST API key or Admin user's API key
- An optional pagination value
API Explorer: Alerts Incidents > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_incidents.json' \ -H 'X-Api-Key:{api_key}' -i
Alert entity conditions
These API functions include links to the API Explorer, where you can list, add and remove entities in the conditions for your alert policies in New Relic Alerts.
If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
- List condition by entity
-
To view the Alerts conditions an entity is part of, for New Relic APM, Browser, Mobile, key transactions, and Plugins, include these values in the API call:
- Your REST API key or Admin user's API key
- The
entity_id
This is the specific entity (alert target) to be monitored. -
The
entity_type
, which must be one of the following:- Application
- BrowserApplication
- MobileApplication
- KeyTransaction
- Plugin
API Explorer: Alerts Entity Conditions > GET > list
curl -X GET 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \ -H 'X-Api-Key:{api_key}' -i \ -G -d 'entity_type={entity_type}'
- Add an entity to a condition
-
To add an entity to a condition, include these values in the API call:
- Your Admin user's API key
- The
entity_id
This is the entity (alert target) to be monitored. It is the numeric ID for the New Relic APM application, browser app, plugin, key transaction, or mobile app. - The
condition_id
(available from API Explorer: Alerts Conditions > GET > List) -
The
entity_type
, which must be one of the following:- Application
- BrowserApplication
- MobileApplication
- KeyTransaction
- Plugin
API Explorer: Alerts Entity Conditions > PUT > Add
curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \ -H 'X-Api-Key:{api_key}' -i \ -H 'Content-Type: application/json' \ -G -d 'entity_type={entity_type}&condition_id={condition_id}'
- Remove an entity from a condition
-
To remove an entity being monitored from a condition, include these values in the API call:
- Your Admin user's API key
- The
entity_id
This is the specific monitored entity (alert target) to be removed. It is the numeric ID for the APM application, browser app, plugin, key transaction, or mobile app. - The
condition_id
(available from API Explorer: Alerts Conditions > GET > List) -
The
entity_type
, which must be one of the following:- Application
- BrowserApplication
- MobileApplication
- KeyTransaction
- Plugin
API Explorer: Alerts Entity Conditions > DELETE > Remove
curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \ -H 'X-Api-Key:{api_key}' -i \ -G -d 'entity_type={entity_type}&condition_id={condition_id}'