Alerts API

list

GET /api/2/organizations/:organization_id/projects/:project_id/alerts

Example Response

HTTP Status: 200 OK
[
  {
    "id": 1,
    "project_id": 2,
    "name": "test alert",
    "expression": "disk.available < 50",
    "duration": 60,
    "alert_emails": "me@example.com",
    "alert_phones": "",
    "alert_endpoint": "",
    "created_at": "2016-01-29T21:35:42.371Z",
    "updated_at": "2016-01-29T21:35:42.371Z",
    "lock_version"": 0
  },
  {
    "id": 2,
    "project_id": 2,
    "name": "Important Alert",
    "expression": "queue.size > 100",
    "duration": 60,
    "alert_emails": "oncalldev@example.com",
    "alert_phones": "",
    "alert_endpoint": "",
    "created_at": "2016-01-29T21:36:22.608Z",
    "updated_at": "2016-01-29T21:36:22.608Z",
    "lock_version": 0
  }
]

show

GET /api/2/organizations/:organization_id/projects/:project_id/alerts/:alert_id

Example Response

HTTP Status: 200 OK
{
  "id": 2,
  "project_id": 2,
  "name": "Important Alert",
  "expression": "queue.size > 100",
  "duration": 60,
  "alert_emails": "oncalldev@example.com",
  "alert_phones": "",
  "alert_endpoint": "",
  "created_at": "2016-01-29T21:36:22.608Z",
  "updated_at": "2016-01-29T21:36:22.608Z",
  "lock_version": 0
}

create

POST /api/2/organizations/:organization_id/projects/:project_id/alerts/

Required Parameters

Optional Parameters

  • duration integer, defaults to 60, length of period to check in seconds (i.e. check the last minute of data)
  • alert_emails string, comma separated list of email addresses to notify
  • alert_phones string, comma separated list of phone numbers to text
  • alert_endpoint string, url to call when alert fires

Example Post Body

{
  "name": "Disk Space",
  "expression": "disk.available < 10",
  "alert_endpoint": "http://example.com/alert_handling_endpoint"
}

Example Response

HTTP Status: 201 CREATED
{
  "id": 3,
  "project_id": 2,
  "name": "Disk Space",
  "expression": "disk.available < 10",
  "duration": 60,
  "alert_emails": null,
  "alert_phones": null,
  "alert_endpoint": "http://example.com/alert_handling_endpoint",
  "created_at": "2016-01-29T21:51:03.289Z",
  "updated_at": "2016-01-29T21:51:03.289Z",
  "lock_version": 0
}

update

PATCH /api/2/organizations/:organization_id/projects/:project_id/alerts/:alert_id

Optional Parameters

  • name string, limit 255
  • expression string, see Instrumental Query Language for valid expressions
  • duration integer, defaults to 60, length of period to check in seconds (i.e. check the last minute of data)
  • alert_emails string, comma separated list of email addresses to notify
  • alert_phones string, comma separated list of phone numbers to text
  • alert_endpoint string, url to call when alert fires

Example Post Body

{
  "expression": "disk.available < 20"
}

Example Post Body

HTTP Status: 204 NO CONTENT
{
  "id": 3,
  "project_id": 2,
  "name": "Disk Space",
  "expression": "disk.available < 20",
  "duration": 60,
  "alert_emails": null,
  "alert_phones": null,
  "alert_endpoint": "http://example.com/alert_handling_endpoint",
  "created_at": "2016-01-29T21:51:03.289Z",
  "updated_at": "2016-01-29T21:52:06.349Z",
  "lock_version": 0
}

destroy

DELETE /api/2/organizations/:organization_id/projects/:project_id/alerts/:alert_id

Example Response

HTTP Status: 200 OK