Our REST API (v2) allows you to configure settings for 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 UI.
In general, any role can use a user key or REST API key with GET > List functions to view alerts data. The account Owner and Admins may use their API key.
List output will be paginated. Available functions include:
You may have an Owner or Admin role in your account and a user keyor have a custom role that grants permissions to manage Alerts and a user 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.
The "hash" place holder in this example must be replaced by one of the following JSON blocks with the appropriate values substituted:
{
"recipients" : "test@google.com",
"include_json_attachment" : true
}
{
"api_key": "abc123",
"teams": "team1",
"tags": "tag1",
"recipients": "me@me.com"
}
{
"url": "http://example.com",
"channel": "channel1"
}
{
"key": "mykey",
"route_key": "theroute"
}
{
"service_key": "myservicekey"
}
This example shows the default payload inserted. (The payload 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.
Important
The condition_id is deprecated. Instead, use condition_family_id.
This example shows the default payload inserted. (The payload 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.
Important
The condition_id is deprecated. Instead, use condition_family_id.
To delete an existing notification channels, use your user key, and include the channel_id (available from API Explorer:Alerts Channels > GET > List) in the API call:
These API functions include links to the API Explorer, where you can create, update, delete, or list policy conditions. 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
Important
The API Explorer provides information about other types of conditions using separate endpoints, including external services (APM and mobile), and synthetic monitoring. 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.
To add conditions to policies, include these values in the API call:
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer:Alerts Conditions > GET > List.
To update conditions for policies, include these values in the API call:
Recommendation: Due to the way NRQL data is streamed, set the aggregation_method to EVENT_FLOW and use the default settings of 60 for aggregation_window and 120 for aggregation_delay. EVENT_FLOW works in most use-cases, but for a discussion on which use cases work better with EVENT_TIMER, see Which aggregation method to use?.
If you set type as outlier, you can omit the value_function. However, two additional fields are required: expected_groups and ignore_overlap. For more information, see Alerts Conditions API field names.
If you omit type or set it as static, it will default to standard NRQL alerting.
To update NRQL conditions for policies, include these values in the API call:
These API functions include links to the API Explorer, where you can create, update, delete, or list policy conditions. These calls are for conditions for external services. The API calls can be used with APM and mobile monitoring apps.
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer:Alerts External Service Conditions > GET > List.
To update conditions for external services to policies that have APM or mobile monitoring apps, include these values in the API call:
To view a list of existing conditions for policies with external service apps (APM or mobile monitoring), use your user key or REST API key and the associated policy_id in the API call.
API Explorer:Alerts External Service Conditions > GET > List
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 Synthetic monitoring.
To add conditions to policies for Synthetic monitoring, include these values in the API call:
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer:Alerts Synthetics Conditions > GET > List.
To update policy conditions for Synthetic monitoring, include these values in the API call:
To view a list of existing policy conditions for Synthetic monitoring, use your user key or REST API key, and the associated policy_id in the API call.
API Explorer:Alerts Synthetics Conditions > GET > List
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.
To add conditions to policies for plugin components or instances, include these values in the API call:
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer:Alerts Plugins Conditions > GET > List.
To update policy conditions for plugin components or instances, include these values in the API call:
To view a list of existing conditions for policies with plugin components or instances, use your user key or REST API key, and the associated policy_id in the API call.
Other optional values to use as filters (described in the API Explorer page) that depend on the type of product (browser monitoring, mobile monitoring, etc.), entity (as apps or key transactions for APM, synthetic monitoring, etc.), and type of event (notification, deployment, instrumentation, etc.)
curl -X GET 'https://api.newrelic.com/v2/alerts_violations.json' \
-H 'Api-Key:$API_KEY' -i
Tip
To find policy, condition, and incident information: take the IDs found in the links section in the violations property and place them into the URLs contained in the outer links property of the payload.
To view incidents for any entity monitored for your account, include these values in the API call:
The entity_id This is the entity (alert target) to be monitored. It is the numeric ID for the APM application, browser app, 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:
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, 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