Alert Policies¶
newrelic_api.alert_policies¶
- class newrelic_api.alert_policies.AlertPolicies(api_key=None)¶
An interface for interacting with the NewRelic Alert Policies API.
- __init__(api_key=None)¶
Parameters: api_key (str) – The API key. If no key is passed, the environment variable NEW_RELIC_API_KEY is used. Raises: If the api_key parameter is not present, and no environment variable is present, a newrelic_api.exceptions.ConfigurationException is raised.
- list(filter_name=None, filter_type=None, filter_ids=None, filter_enabled=None, page=None)¶
This API endpoint returns a paginated list of the alert policies associated with your New Relic account. Alert policies can be filtered by their name, list of IDs, type (application, key_transaction, or server) or whether or not policies are archived (defaults to filtering archived policies).
Parameters: Return type: dict
Returns: The JSON response of the API, with an additional ‘pages’ key if there are paginated results
{ "alert_policies": [ { "id": "integer", "type": "string", "name": "string", "enabled": "boolean", "conditions": [ { "id": "integer", "type": "string", "severity": "string", "threshold": "float", "trigger_minutes": "integer", "enabled": "boolean" } ], "links": { "notification_channels": [ "integer" ], "applications": [ "integer" ], "key_transactions": [ "integer" ], "servers": [ "integer" ] } } ], "pages": { "last": { "url": "https://api.newrelic.com/v2/alert_policies.json?page=2", "rel": "last" }, "next": { "url": "https://api.newrelic.com/v2/alert_policies.json?page=2", "rel": "next" } } }
- show(id)¶
This API endpoint returns a single alert policy, identified by ID.
Parameters: id (int) – Alert policy ID Return type: dict Returns: The JSON response of the API { "alert_policy": { "id": "integer", "type": "string", "name": "string", "enabled": "boolean", "conditions": [ { "id": "integer", "type": "string", "severity": "string", "threshold": "float", "trigger_minutes": "integer", "enabled": "boolean" } ], "links": { "notification_channels": [ "integer" ], "applications": [ "integer" ], "key_transactions": [ "integer" ], "servers": [ "integer" ] } } }
- update(id, policy_update)¶
This API endpoint allows you to update your alert policies.
The input is expected to be in JSON format in the body parameters of the PUT request. The exact schema is defined below. Any extra parameters passed in the body will be ignored .:
{ "alert_policy": { "name": str, "enabled": bool, "conditions": [ { "id": int, "threshold": float, "trigger_minutes": int, "enabled": bool } ], "links": { "notification_channels": [ int ], "applications": [ int ], "key_transactions": [ "int ], "servers": [ int ] } } }
NOTE: When updating alertable and notification channel links, the list sent replaces the existing list. Invalid values will be ignored but an empty array will result in alertables/channels being reset.
Parameters: Return type: dict
Returns: The JSON response of the API
{ "alert_policy": { "id": "integer", "type": "string", "name": "string", "enabled": "boolean", "conditions": [ { "id": "integer", "type": "string", "severity": "string", "threshold": "float", "trigger_minutes": "integer", "enabled": "boolean" } ], "links": { "notification_channels": [ "integer" ], "applications": [ "integer" ], "key_transactions": [ "integer" ], "servers": [ "integer" ] } } }