Skip to main content

alerts

Creates, updates, deletes, gets or lists an alerts resource.

Overview

Namealerts
TypeResource
Iddigitalocean.monitoring.alerts

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with a key called alert. The value of this will be an object that contains the standard attributes associated with an uptime alert.

NameDatatypeDescription
idstring (uuid)A unique ID that can be used to identify and reference the alert. (example: 5a4981aa-9653-4bd1-bef5-d6bff52042e4)
namestringA human-friendly display name. (example: Landing page degraded performance)
comparisonstringThe comparison operator used against the alert's threshold. (example: greater_than)
notificationsobjectThe notification settings for a trigger alert.
periodstringPeriod of time the threshold must be exceeded to trigger the alert. (example: 2m)
thresholdintegerThe threshold at which the alert will enter a trigger state. The specific threshold is dependent on the alert type.
typestringThe type of alert. (example: latency)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
uptime_get_alertselectcheck_id, alert_idTo show information about an existing alert, send a GET request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID.
uptime_list_alertsselectcheck_idper_page, pageTo list all of the alerts for an Uptime check, send a GET request to /v2/uptime/checks/$CHECK_ID/alerts.
uptime_create_alertinsertcheck_id, data__name, data__type, data__notifications, data__periodTo create an Uptime alert, send a POST request to /v2/uptime/checks/$CHECK_ID/alerts specifying the attributes
in the table below in the JSON body.
uptime_update_alertreplacecheck_id, alert_id, data__name, data__type, data__notifications, data__periodTo update the settings of an Uptime alert, send a PUT request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID.
uptime_delete_alertdeletecheck_id, alert_idTo delete an Uptime alert, send a DELETE request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID. A 204 status
code with no body will be returned in response to a successful request.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
alert_idstring (uuid)A unique identifier for an alert. (example: 17f0f0ae-b7e5-4ef6-86e3-aa569db58284)
check_idstring (uuid)A unique identifier for a check. (example: 4de7ac8b-495b-4884-9a69-1050c6793cd6)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)

SELECT examples

To show information about an existing alert, send a GET request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID.

SELECT
id,
name,
comparison,
notifications,
period,
threshold,
type
FROM digitalocean.monitoring.alerts
WHERE check_id = '{{ check_id }}' -- required
AND alert_id = '{{ alert_id }}' -- required;

INSERT examples

To create an Uptime alert, send a POST request to /v2/uptime/checks/$CHECK_ID/alerts specifying the attributes
in the table below in the JSON body.

INSERT INTO digitalocean.monitoring.alerts (
data__name,
data__type,
data__threshold,
data__comparison,
data__notifications,
data__period,
check_id
)
SELECT
'{{ name }}' --required,
'{{ type }}' --required,
{{ threshold }},
'{{ comparison }}',
'{{ notifications }}' --required,
'{{ period }}' --required,
'{{ check_id }}'
RETURNING
alert
;

REPLACE examples

To update the settings of an Uptime alert, send a PUT request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID.

REPLACE digitalocean.monitoring.alerts
SET
data__name = '{{ name }}',
data__type = '{{ type }}',
data__threshold = {{ threshold }},
data__comparison = '{{ comparison }}',
data__notifications = '{{ notifications }}',
data__period = '{{ period }}'
WHERE
check_id = '{{ check_id }}' --required
AND alert_id = '{{ alert_id }}' --required
AND data__name = '{{ name }}' --required
AND data__type = '{{ type }}' --required
AND data__notifications = '{{ notifications }}' --required
AND data__period = '{{ period }}' --required
RETURNING
alert;

DELETE examples

To delete an Uptime alert, send a DELETE request to /v2/uptime/checks/$CHECK_ID/alerts/$ALERT_ID. A 204 status
code with no body will be returned in response to a successful request.

DELETE FROM digitalocean.monitoring.alerts
WHERE check_id = '{{ check_id }}' --required
AND alert_id = '{{ alert_id }}' --required;