POST /v2/alerts/
Request format:
{
"name": "string",
"metric": "string",
"alert_criteria":
{
"type": "above" | "below" | "outside_bounds" | "missing",
"above_value": 123,
"below_value": 123,
"time_period": 123,
},
"additional_criteria":
{
"b":
{
"type": "above" | "below" | "outside_bounds" | "missing",
"above_value": 123,
"below_value": 123,
"time_period": 123,
"metric": "string"
}
},
"expression": "a && b",
"scheduled_mutes": ["scheduled_mute_id1", "scheduled_mute_id2", "scheduled_mute_id3"],
"notification_channels": ["channel_id1", "channel_name1", "channel_id2"],
"notification_type": "state_change" | ["state_change"] | ["every", 123],
"info": "string",
"on_query_failure": null | "ignore" | "notify"
}
Parameters:
{"f": {"type": "above", "above_value": 5, "metric": "additional.metric.to.alert.on"}
where f is also referenced in the expression field. Defaults to {}.Alert criteria examples:
Create an alert that triggers if the metric is missing for 10 minutes.
"alert_criteria": {
"type": "missing",
"time_period": 10
}
Create an alert that triggers if the metric is above 5.6 ever.
"alert_criteria": {
"type": "above",
"above_value": 5.6
}
Create an alert that triggers if the metric is below 2.1 or above 5.6 ever.
"alert_criteria": {
"type": "outside_bounds",
"above_value": 5.6,
"below_value": 2.1
}
Create an alert that triggers if the metric is below 2.1 or above 5.6 for 10 minutes
"alert_criteria": {
"type": "outside_bounds",
"above_value": 5.6,
"below_value": 2.1,
"time_period": 10
}
Composite Alerts
Create an alert when one metric is above 80 and another is below 20
"metric": "my.first.metric",
"alert_criteria": {
"type": "above",
"above_value": 80
},
"additional_criteria": {
"b": {
"type": "below",
"below_value": 20,
"metric": "my.second.metric"
}
},
"expression": "a && b",
Create an alert when one metric is below 50 or another is below 30
"metric": "my.first.metric",
"alert_criteria": {
"type": "above",
"above_value": 50
},
"additional_criteria": {
"c": {
"type": "below",
"below_value": 30,
"metric": "my.second.metric"
}
},
"expression": "a || c"
Create an alert when one metric (A) is below 50 and another (B) is above 60 or if a third (C) is above 120. Note that performing an && on two monitors gets preference over || so this alert expression will be evaluated as (A && B) || C
"metric": "my.first.metric",
"alert_criteria": {
"type": "below",
"below_value": 50
},
"additional_criteria": {
"b": {
"type": "above",
"above_value": 60,
"metric": "my.second.metric"
},
"c": {
"type": "above",
"above_value": 120,
"metric": "my.third.metric"
}
},
"expression": "A && B || C"
Curl example:
curl -H "Content-Type: application/json" -X POST -d \
'{"name": "alert1", "metric": "test.metric.1", "alert_criteria": {"type": "above", "above_value": 5, "time_period": 2}}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/"
Creates an alert named alert1 for metric test.metric.1 that triggers if the value is above 5 for 2 minutes with the Email me notification type.
Response format:
HTTP/1.1 201
Content-Type: application/json
{
"id": "<alert_id>",
"url": "/v2/alerts/<alert_id>"
}
Parameters:
Status Codes:
GET /v2/alerts/? - Returns a JSON object containing information on alerts matching the search query. Returns all the alerts if the parameter is left empty.
Curl example:
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/?"
Available Parameters (default values in brackets):
Specifying both alert_name and alert_id performs an OR operation and returns alert that match either criteria. Including a search string performs an AND operation with the other criteria.
Response format:
HTTP/1.1 201
Content-Type: application/json
{
"alerts": [
{
"name": "Name of the alert",
"id": "unique id of the alert",
"alert_criteria": {
"type": "type of alert",
"above_value": 123,
"below_value": 123,
"time_period": 123
}
"notification_channels": ["<list of channel ids>"],
"notification_type": ["state_change" ] | ["every", 123],
"scheduled_mutes": ["<list of scheduled mute ids"],
"currently_triggered_metrics": [] | ["List of metrics that triggered the alert."],
"muted": True | False,
"status": "alerting" | "healthy",
"info": "alert info" | null,
"on_query_failure": null | "notify" | "ignore"
}
]
"next_page": False | page number
}
Status Codes:
GET /v2/alerts/<alert_id>/ - Returns information on a single alert.
Curl example:
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/"
Obtain information on the alert identified by the id 123-456-789.
Alert response format:
HTTP/1.1 200
Content-Type: application/json
{
"name": "Name of the alert",
"id": "unique id of the alert",
"alert_criteria": {
"type": "type of alert",
"above_value": 123,
"below_value": 123,
"time_period": 123
},
"expression": "a",
"notification_channels": ["<list of channel ids>"],
"scheduled_mutes": ["<list of scheduled mute ids>"],
"currently_triggered_metrics": [] | ["List of metrics that triggered the alert."],
"notification_type": ["state_change" ] | ["every", 123],
"muted": True | False,
"status": "alerting" | "healthy",
"info": "alert info" | null,
"on_query_failure": null | "notify" | "ignore"
}
Status Codes:
PUT /v2/alerts/<alert_id>/ - Update attributes of an alert identified by the alert id.
Curl Example
curl -H "Content-Type: application/json" -X PUT -d \
'{"alert_criteria": {"time_period": 3, "type": "below", "below_value": 6}}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/"
Modify the alert identified by the id 123-456-789 to alert if the metric values are below 6 for 3 minutes.
Request format:
{
"name": "string",
"metric": "string",
"info": "string",
"alert_criteria":
{
"type": "above" | "below" | "outside_bounds" | "missing",
"above_value": 123,
"below_value": 123,
"time_period": 123
},
"scheduled_mutes": ["scheduled_mute_id1", "scheduled_mute_id2", "scheduled_mute_id3"],
"notification_channels": ["channel_id1", "channel_id2", "channel_id3"],
"notification_type": "state_change" | ["state_change"] | ["every", X],
}
Each field is optional and only the specified fields are updated.
Status Codes:
DELETE /v2/alerts/<alert_id>/ - Update an alert identified by the alert id.
Curl Example
curl -X DELETE "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/"
Delete the alert identified by the id 123-456-789.
Status Codes:
POST /v2/alerts/<alert_id>/muted/ - Mute alerts identified by the alert id.
Curl Example
curl -H "Content-Type: application/json" -X POST -d '{"duration":60}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/muted/"
Mute the alert identified by the id 123-456-789 for 60 minutes.
Request format:
HTTP/1.1 200
Content-Type: application/json
{"duration": 60}
Parameters:
Status Codes:
DELETE /v2/alerts/<alert_id>/muted/ - Unmute an alert identified by the alert id.
Curl Example
curl -X DELETE "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/muted/"
Unmute the alert identified by the id 123-456-789`.
Status Codes:
GET /v2/alerts/<alert_id>/muted/ - Get the mute status of an alert identified by the alert id.
Curl Example
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/123-456-789/muted/"
Obtain information on the mute status of the alert identified by the id 123-456-789. Also provides a list of the scheduled mutes currently attached to the alert.
Response format:
HTTP/1.1 200
Content-Type: application/json
{
"id": "alert_id",
"name": "alert_name",
"muted": True | False,
"duration": Remaining time in minutes,
"scheduled_mutes": ["<list of scheduled mute ids>"]
}
Status Codes:
POST /v2/alerts/muted/ - Mute multiple alerts.
Curl examples:
curl -H "Content-Type: application/json" -X POST -d '{"ids": ["123-456-789", "321-654-987"], "duration":60}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/muted/"
Mute alerts 123-456-789 and 321-654-987 for 60 minutes.
curl -H "Content-Type: application/json" -X POST -d '{"search": "search_string", "duration":60}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/muted/"
Mute alerts with alert name, metric name or notification channel name containing search_string for 60 minutes.
Request format:
HTTP/1.1 200
Content-Type: application/json
{"ids": ["alert_id1", "alert_id2"],
"duration": 60}
HTTP/1.1 200
Content-Type: application/json
{"search": "search_string",
"duration": 60}
Parameters:
If both ids and search are empty, then all alerts will be muted.
Status Codes:
DELETE /v2/alerts/muted/ - Mute multiple alerts.
Curl examples:
curl -H "Content-Type: application/json" -X POST -d '{"ids": ["123-456-789", "321-654-987"]}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/muted/"
Unmute alerts 123-456-789 and 321-654-987.
curl -H "Content-Type: application/json" -X POST -d '{"search": "search_string"}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/muted/"
Unmute alerts with alert name, metric name or notification channel name containing search_string.
Request format:
HTTP/1.1 200
Content-Type: application/json
{"ids": ["alert_id1", "alert_id2"]}
HTTP/1.1 200
Content-Type: application/json
{"search": "search_string"}
Parameters:
If both ids and search are empty, then all alerts will be unmuted.
Status Codes:
GET /v2/alerts/history/? - Obtain the alert history.
Curl example:
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/history/?id=123-456-789
Obtain alert history of the alert identified by the id 123-456-789.
Available Parameters (default values in brackets):
Response format:
HTTP/1.1 200
Content-Type: application/json
{
{"<alert_id_1>": [{
"status": "alerting" | "recovered",
"value": null | 123,
"time": "unix_timestamp",
"metric": "The metric that triggered this."
},],
}
{"<alert_id_2>": [{
"status": "alerting" | "healthy",
"value": null | 123,
"time": "unix_timestamp",
"metric": "The metric that triggered this."
},],
}
}
Status Codes: