The REST 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.
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 anomalies
NRQL: Anomalies
Alert policies
These API functions include links to the API Explorer, where you can create, delete, or list policies.
To delete an existing policy, use your user key, and include the policy_id (available from API Explorer > Alerts Policies > GET > List) in the API call:
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 conditions are not available from this API endpoint:
Conditions targeting labels (dynamic targeting)
Web transaction percentile conditions
Anomaly 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:
Your
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)
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?.
API Explorer > Alerts NRQL Conditions > POST > Create
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 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 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
Multi-location conditions for synthetic monitoring
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 for multi-location conditions with synthetic monitoring. Before creating or updating a condition, read the rules for multi-location alert conditions.
To add conditions to policies for multi-location 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 Location Failure Conditions > GET > List.
To update policy conditions for multi-location synthetic monitoring, include these values in the API call:
To view a list of existing policy conditions for multi-location synthetic monitoring, use your user key or REST API key, and the associated policy_id in the API call.
API Explorer > Alerts Location Failure Conditions > GET > List
curl -X GET 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json' \
-H 'X-Api-Key:$API_KEY' -i
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.
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 'X-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 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
API Explorer > Alerts Entity Conditions > PUT > Add
The entity_id This is the specific monitored entity (alert target) to be removed. It is the numeric ID for the 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
API Explorer > Alerts Entity Conditions > DELETE > Remove