Справочник API по мониторам

Возможные значения полей

Локация монитора

ЗначениеОписание
US_EAST_1Сев. Вирджиния
CA_CENTRAL_1Канада (Монреаль)
EU_CENTRAL_1Франкфурт
AP_NORTHEAST_1Токио

Типы оповещений монитора

ЗначениеОписание
INCIDENTОповещение об инциденте
EMAILОповещение по email
SMSОповещение по SMS
SLACKОповещение в Slack
DISCORDОповещение в Discord
MICROSOFT_TEAMSОповещение в Microsoft Teams
PHONE_CALLОповещение телефонным звонком
WEBHOOKОповещение через вебхук
GOOGLE_CHATОповещение в Google Chat
WHATSAPPОповещение в WhatsApp

Статус монитора

ЗначениеОписание
UPМонитор работает нормально
DOWNМонитор упал
DEGRADEDУ монитора есть проблемы
UNKNOWNСостояние монитора не определено

Получить мониторы

Через этот эндпоинт можно найти нужный монитор и пролистать список всех существующих мониторов.

Эндпоинт:

GET /:page_id/monitors

Параметры запроса

ПараметрТипПо умолчаниюОписание
pagenumber1Номер запрашиваемой страницы.
limitnumber100Число мониторов на странице.
searchstringnullПоисковый запрос для фильтрации результатов.
statusenumnullФильтр по статусу ('UP', 'DOWN', 'UNKNOWN', 'DEGRADED').

Пример запроса

GET /1/monitors?limit=3&page=2&status=DOWN

Пример ответа

{
"monitors": [{ "...": "monitor objects" }],
"total": 10,
"page": 3,
"totalPages": 5,
"limit": 2
}

Создать монитор

Эндпоинт:

POST /monitors

Пример запроса

{
"pageId": "page123",
"url": "https://example.com",
"httpMethod": "GET",
"body": null,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token"
},
"queryParams": {
"search": "test",
"limit": "10"
},
"basicAuth": {
"username": "user",
"password": "password"
},
"type": "HTTP",
"assertions": [
{
"type": "STATUSCODE",
"comparison": "EQUALS",
"selector": null,
"target": "200"
}
],
"alerts": ["alert-id-1", "alert-id-2"],
"name": "Example Monitor",
"locations": "US_EAST_1",
"checksInterval": 300,
"createComponent": true,
"createMetric": true,
"onFail": {
"createIncident": true,
"createOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
},
"onRecover": {
"resolveIncident": true,
"resolveOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
}
}

Пример ответа

{
"monitor": {
"pageId": "page123",
"url": "https://example.com",
"httpMethod": "GET",
"body": null,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token"
},
"queryParams": {
"search": "test",
"limit": "10"
},
"basicAuth": {
"username": "user",
"password": "password"
},
"type": "HTTP",
"assertions": [
{
"id": "assertion1",
"type": "STATUSCODE",
"comparison": "EQUALS",
"selector": null,
"target": "200"
}
],
"alerts": ["alert1", "alert2"],
"name": "Example Monitor",
"locations": "US_EAST_1",
"checksInterval": 300,
"createComponent": true,
"createMetric": true,
"onFail": {
"createIncident": true,
"createOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
},
"onRecover": {
"resolveIncident": true,
"resolveOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
},
"createdAt": "2023-08-08T12:00:00Z",
"updatedAt": "2023-08-08T12:00:00Z"
},
"message": "Monitor created successfully"
}

Обновить монитор

Эндпоинт:

PUT /monitors/:id

Пример запроса

{
"url": "https://updated.com",
"name": "Updated Monitor Name"
}

Пример ответа

{
"monitor": {
"pageId": "page123",
"url": "https://updated.com",
"httpMethod": "GET",
"body": null,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token"
},
"queryParams": {
"search": "test",
"limit": "10"
},
"basicAuth": {
"username": "user",
"password": "password"
},
"type": "HTTP",
"assertions": [
{
"id": "assertion1",
"type": "STATUSCODE",
"comparison": "EQUALS",
"selector": null,
"value": "200"
}
],
"alerts": ["alert1", "alert2"],
"name": "Updated Monitor Name",
"locations": "US_EAST_1",
"checksInterval": 300,
"createComponent": true,
"createMetric": true,
"onFail": {
"createIncident": true,
"createOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
},
"onRecover": {
"resolveIncident": true,
"resolveOutageDuration": true,
"publishIncident": true,
"notifySubscribers": true
},
"createdAt": "2023-08-08T12:00:00Z",
"updatedAt": "2023-08-08T12:00:00Z"
},
"message": "Monitor updated successfully"
}

Удалить монитор

Эндпоинт:

DELETE /monitors/:id

Пример запроса

DELETE /monitors/monitor-id-1

Пример ответа

{
"message": "Monitor deleted successfully."
}

Получить логи монитора

Эндпоинт:

GET /monitors/:id/logs

Параметры запроса

ПараметрТипПо умолчаниюОписание
limitnumber100Число элементов на странице. Не больше 1000.
pagenumber1Номер запрашиваемой страницы.
monitorIdstring-ID монитора.
locationstringnullЛокация монитора.
createdAtstring | object | numbernullДата создания. Строка, число или объект с полями gte и lte.
isSuccessfulbooleannullБыла ли проверка успешной.
isSSLCheckbooleannullЯвляется ли проверка SSL-проверкой.
httpStatusCodestringnullHTTP-код статуса ответа.
status('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')nullСтатус монитора.
dnsTimestring | number | objectnullВремя разрешения DNS.
tcpTimestring | number | objectnullВремя установки TCP-соединения.
tlsTimestring | number | objectnullВремя TLS-рукопожатия.
firstByteTimestring | number | objectnullВремя до получения первого байта.
downloadTimestring | number | objectnullВремя загрузки.
responseTimestring | number | objectnullОбщее время отклика.
performanceTimestring | number | objectnullВремя производительности.
accessabilityScorestring | number | objectnullОценка доступности.
seoScorestring | number | objectnullОценка SEO.
bestPracticesScorestring | number | objectnullОценка следования лучшим практикам.
successfulAssertionsstring | number | objectnullЧисло успешных проверок.
sortstringхронологическиПоле для сортировки.

Пример запроса

GET /monitors/monitor-id-1/logs?limit=100&page=1

Пример ответа

{
"monitorLogs": [
// {monitor log object},
// {monitor log object 2}
],
"total": 478,
"page": 1,
"totalPages": 5,
"limit": 100
}

Запустить проверку монитора по ID

Эндпоинт:

GET /monitors/:id/run

Параметры запроса

ПараметрТипПо умолчаниюОписание
location'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'-Локация монитора. Должна быть одним из указанных значений.
retrybooleanfalseНужно ли повторить операцию. Необязательно.
monitorLogIdstringnullУникальный идентификатор лога монитора. Необязательно.

Пример запроса

GET /monitors/monitor-id-1/run?monitorId=abc123&location=US_EAST_1&retry=true&monitorLogId=log456

Пример ответа

{
"status": "success",
"message": "Monitor check run successfully."
}

Создать оповещение монитора

Эндпоинт:

POST /monitor-alerts

Пример запроса

{
"type": "EMAIL",
"pageId": "page123",
"recipient": "user@example.com",
"recipientWorkspace": "workspace123",
"whenFails": true,
"whenRecovers": true,
"whenDegrades": false,
"whenSslExpires": true,
"sslExpiresInDays": 30,
"monitors": ["monitor1", "monitor2"],
"metadata": "Additional information about the alert"
}

Пример ответа

{
"monitor": {
"id": "alert123",
"siteId": "site123",
"type": "EMAIL",
"recipient": "user@example.com",
"whenFails": true,
"whenRecovers": true,
"whenDegrades": false,
"whenSslExpires": true,
"sslExpiresInDays": 30,
"monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
"createdAt": "2023-08-08T12:00:00Z",
"updatedAt": "2023-08-08T12:00:00Z",
"metadata": "Additional information about the alert"
},
"message": "Monitor Alert created successfully"
}

Обновить оповещение монитора

Эндпоинт:

PUT /monitor-alerts/:id

Пример запроса

{
"type": "EMAIL",
"monitors": ["monitor-1-id", "monitor-2-id", "monitor-3-id"]
}

Пример ответа

{
"monitor": {
"type": "EMAIL",
"pageId": "page123",
"recipient": "user@example.com",
"recipientWorkspace": "workspace123",
"whenFails": true,
"whenRecovers": true,
"whenDegrades": false,
"whenSslExpires": true,
"sslExpiresInDays": 30,
"monitors": ["monitor-1-id", "monitor-2-id"],
"metadata": "Additional information about the alert"
},
"message": "Monitor alert updated successfully."
}

Получить оповещения монитора

Эндпоинт:

GET /:page_id/monitor-alerts

Параметры запроса

ПараметрТипПо умолчаниюОписание
limitnumber100Число элементов на странице.
pagenumber1Номер запрашиваемой страницы.

Пример запроса

GET /1/monitor-alerts?limit=2&page=3

Пример ответа

{
"monitorAlerts": [
{...monitor alert objects}
],
"total": 27,
"page": 3,
"totalPages": 14,
"limit": 2
}

Удалить оповещение монитора

Эндпоинт:

DELETE /monitor-alerts/:id

Пример запроса

DELETE /monitor-alerts/alert-id-1

Пример ответа

{
"message": "Monitor alert deleted successfully."
}

Создать группу мониторов

Эндпоинт:

POST /monitors-groups

Пример запроса

{
"pageId": "page123",
"name": "Example Name",
"childId": "child456"
}

Пример ответа

{
"monitor": {
"id": "group123",
"name": "Example Name",
"siteId": "site123",
"collapsed": false,
"monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
"groupId": "parentGroup123",
"children": [
{ "id": "childGroup1", "name": "Child Group 1" },
{ "id": "childGroup2", "name": "Child Group 2" }
],
"order": 1,
"createdAt": "2023-08-08T12:00:00Z",
"updatedAt": "2023-08-08T12:00:00Z",
"parents": ["parent1", "parent2"],
"componentId": "component123"
},
"message": "Monitor group created successfully."
}

Обновить группу мониторов

Эндпоинт:

PUT /monitors-groups/:id

Пример запроса

{
"name": "Updated Monitor Group Name"
}

Пример ответа

{
"monitor": {
"id": "group123",
"name": "Updated Monitor Group Name",
"siteId": "site123",
"collapsed": true,
"monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
"groupId": "parentGroup123",
"children": [
{ "id": "childGroup1", "name": "Child Group 1" },
{ "id": "childGroup2", "name": "Child Group 2" }
],
"order": 1,
"createdAt": "2023-08-08T12:00:00Z",
"updatedAt": "2023-08-08T12:00:00Z",
"parents": ["parent1", "parent2"],
"componentId": "component123"
},
"message": "Monitor group updated successfully."
}

Удалить группу мониторов

Эндпоинт:

DELETE /monitors-groups/:id

Пример запроса

DELETE /monitors-groups/group-id-1

Пример ответа

{
"message": "Monitor group deleted successfully."
}

Добавить мониторы в группу

Эндпоинт:

POST /monitors-groups/:id/monitors

Пример запроса

{
"monitors": ["monitor1", "monitor2", "monitor3"]
}

Пример ответа

{
"message": "Monitors added to the group successfully."
}

Запустить проверку группы мониторов

Эндпоинт:

GET /monitors-groups/:id/run

Параметры запроса

ПараметрТипПо умолчаниюОписание
location'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'-Локация монитора. Должна быть одним из указанных значений.
retrybooleanfalseНужно ли повторить операцию. Необязательно.
monitorLogIdstringnullУникальный идентификатор лога монитора. Необязательно.

Пример запроса

GET /monitors-groups/group-id-1/run

Пример ответа

{
"result": "OK",
"monitorLogId": "monitor-log-id-1"
}

Cron-мониторы

Cron-мониторы отслеживают задачи по расписанию через HTTP-пинги. О настройке в продукте и работе в панели читайте в разделе Мониторинг Cron.

Возможные значения полей

Статус cron-монитора

ЗначениеОписание
UPМонитор работает нормально
DOWNМонитор упал
DEGRADEDУ монитора есть проблемы
UNKNOWNСостояние монитора не определено

Состояние cron-монитора

ЗначениеОписание
ACTIVEМонитор активно проверяется
PAUSEDПроверки монитора приостановлены
MUTEDМонитор заглушён (без уведомлений)

Статус лога cron-монитора

ЗначениеОписание
SUCCESSЗадача успешно завершена
FAILUREЗадача явно сообщила о сбое
MISSEDЗадача не отправила пинг в ожидаемом окне
LATEЗадача отправила пинг после периода, но в пределах отсрочки
STARTEDЗадача сообщила о старте (замер времени выполнения)

Период и отсрочка

И period, и grace задаются в секундах. period — как часто должна выполняться задача; grace — дополнительное время, после которого монитор считается упавшим.

Получить cron-мониторы

Эндпоинт:

GET /:page_id/monitors/cron

Параметры запроса

ПараметрТипПо умолчаниюОписание
limitnumber100Число cron-мониторов на странице. Максимум 100.
pagenumber1Номер страницы.
searchstringnullПоисковый запрос для фильтрации результатов по названию.
statusenumnullФильтр по статусу ('UP', 'DOWN', 'UNKNOWN', 'DEGRADED').

Пример запроса

GET /page123/monitors/cron?limit=10&page=1&status=DOWN

Пример ответа

{
"cronMonitors": [
{
"id": "cron-abc123",
"name": "Daily backup",
"slug": "my-page-x7k2m9n4p1q8w3e5",
"period": 86400,
"grace": 3600,
"status": "UP",
"state": "ACTIVE",
"siteId": "page123",
"order": 1,
"groupId": null,
"componentId": "component-id-1",
"onFailCreateIncident": true,
"onFailCreateOutageDuration": false,
"onFailPublishIncident": true,
"onFailNotifySubscribers": true,
"onRecoverResolveIncident": true,
"onRecoverResolveOutageDuration": false,
"onRecoverPublishIncident": true,
"onRecoverNotifySubscribers": true,
"createTemplateId": null,
"resolveTemplateId": null,
"createdAt": "2024-01-15T08:00:00.000Z",
"updatedAt": "2024-01-15T08:00:00.000Z"
}
],
"total": 1,
"page": 1,
"totalPages": 1,
"limit": 10
}

Создать cron-монитор

Эндпоинт:

POST /monitors/cron

Пример запроса

{
"pageId": "page123",
"name": "Daily backup",
"period": 86400,
"grace": 3600,
"alerts": ["alert-id-1", "alert-id-2"],
"createComponent": true,
"onFail": {
"createIncident": true,
"createOutageDuration": false,
"publishIncident": true,
"notifySubscribers": true
},
"onRecover": {
"resolveIncident": true,
"resolveOutageDuration": false,
"publishIncident": true,
"notifySubscribers": true
}
}

Пример ответа

{
"cronMonitor": {
"id": "cron-abc123",
"name": "Daily backup",
"slug": "my-page-x7k2m9n4p1q8w3e5",
"period": 86400,
"grace": 3600,
"status": "UP",
"state": "ACTIVE",
"siteId": "page123",
"order": 1,
"groupId": null,
"componentId": "component-id-1",
"onFailCreateIncident": true,
"onFailCreateOutageDuration": false,
"onFailPublishIncident": true,
"onFailNotifySubscribers": true,
"onRecoverResolveIncident": true,
"onRecoverResolveOutageDuration": false,
"onRecoverPublishIncident": true,
"onRecoverNotifySubscribers": true,
"createTemplateId": null,
"resolveTemplateId": null,
"createdAt": "2024-01-15T08:00:00.000Z",
"updatedAt": "2024-01-15T08:00:00.000Z"
},
"message": "Cron monitor created successfully."
}

В ответе есть slug. По нему формируются URL для пингов вашей задачи. Первый успешный пинг запускает фоновую проверку по расписанию.

Обновить cron-монитор

Эндпоинт:

PUT /monitors/cron/:id

Пример запроса

{
"name": "Daily backup (updated)",
"period": 43200,
"grace": 1800,
"state": "PAUSED",
"alerts": ["alert-id-1"],
"onFail": {
"notifySubscribers": false
}
}

Пример ответа

{
"cronMonitor": {
"id": "cron-abc123",
"name": "Daily backup (updated)",
"slug": "my-page-x7k2m9n4p1q8w3e5",
"period": 43200,
"grace": 1800,
"status": "UP",
"state": "PAUSED",
"siteId": "page123",
"order": 1,
"groupId": null,
"componentId": "component-id-1",
"onFailCreateIncident": true,
"onFailCreateOutageDuration": false,
"onFailPublishIncident": true,
"onFailNotifySubscribers": false,
"onRecoverResolveIncident": true,
"onRecoverResolveOutageDuration": false,
"onRecoverPublishIncident": true,
"onRecoverNotifySubscribers": true,
"createTemplateId": null,
"resolveTemplateId": null,
"alerts": [
{
"id": "alert-id-1",
"type": "EMAIL",
"recipient": "ops@example.com"
}
],
"createdAt": "2024-01-15T08:00:00.000Z",
"updatedAt": "2024-01-16T10:30:00.000Z"
},
"message": "Cron monitor updated successfully."
}

Удалить cron-монитор

Эндпоинт:

DELETE /monitors/cron/:id

Пример запроса

DELETE /monitors/cron/cron-abc123

Пример ответа

{
"cronMonitor": {
"id": "cron-abc123",
"name": "Daily backup",
"slug": "my-page-x7k2m9n4p1q8w3e5",
"period": 86400,
"grace": 3600,
"status": "UP",
"state": "ACTIVE",
"siteId": "page123",
"order": 1,
"groupId": null,
"componentId": "component-id-1",
"onFailCreateIncident": true,
"onFailCreateOutageDuration": false,
"onFailPublishIncident": true,
"onFailNotifySubscribers": true,
"onRecoverResolveIncident": true,
"onRecoverResolveOutageDuration": false,
"onRecoverPublishIncident": true,
"onRecoverNotifySubscribers": true,
"createTemplateId": null,
"resolveTemplateId": null,
"createdAt": "2024-01-15T08:00:00.000Z",
"updatedAt": "2024-01-15T08:00:00.000Z"
},
"message": "Cron monitor deleted successfully."
}

Получить логи cron-монитора

Эндпоинт:

GET /monitors/cron/:id/logs

Параметры запроса

ПараметрТипПо умолчаниюОписание
limitnumber100Число логов на странице. Максимум 127.
pagenumber1Номер страницы. Максимум 1000.
startDatestringгод назадНачальная дата диапазона логов в формате ISO 8601.
endDatestringсейчасКонечная дата диапазона логов в формате ISO 8601.
importanceenumnullФильтр логов по важности ('all', 'important').

Пример запроса

GET /monitors/cron/cron-abc123/logs?limit=50&page=1&importance=important

Пример ответа

{
"logs": [
{
"id": "log-xyz789",
"monitorId": "cron-abc123",
"status": "SUCCESS",
"requestType": "GET",
"agent": "curl/8.4.0",
"ipAddress": "203.0.113.10",
"createdAt": "2024-01-16T06:00:00.000Z",
"startedAt": "2024-01-16T05:59:58.000Z"
}
],
"page": 1
}

Получить сводку по cron-монитору

Эндпоинт:

GET /monitors/cron/:id/summary

Пример запроса

GET /monitors/cron/cron-abc123/summary

Пример ответа

{
"summary": {
"totalLogs": 120,
"totalFailedLogs": 3,
"availability": 97.5,
"oneDayAvailability": 100,
"previousDayAvailability": 100,
"sevenDayAvailability": 98.2,
"previousSevenDayAvailability": 96.1,
"thirtyDayAvailability": 97.5,
"previousThirtyDayAvailability": 95.8,
"lastSuccess": "2024-01-16T06:00:00.000Z",
"lastFailure": "2024-01-10T06:00:00.000Z",
"lastStarted": null,
"upSince": "2024-01-10T07:00:00.000Z",
"downSince": null
}
}

Эндпоинты для пингов

Этим эндпоинтам аутентификация не нужна. Секретом служит slug монитора.

Пинговать можно через базовый URL API или через отдельный cron-хост:

  • Успех: https://cron.instatus.com/{slug} или GET / POST / HEAD /monitors/cron/{slug}
  • Сбой: https://cron.instatus.com/{slug}/fail или GET / POST / HEAD /monitors/cron/{slug}/fail
  • Старт: https://cron.instatus.com/{slug}/start или GET / POST / HEAD /monitors/cron/{slug}/start

Отправляйте пинг об успехе каждый раз, когда задача завершается по расписанию. Чтобы фиксировать время выполнения, отправляйте пинг о старте перед запуском задачи, а по завершении — пинг об успехе или о сбое.

Пример успешного пинга

curl https://cron.instatus.com/my-page-x7k2m9n4p1q8w3e5

Пример ответа

{
"id": "log-xyz789",
"monitorId": "cron-abc123",
"status": "SUCCESS",
"requestType": "GET",
"agent": "curl/8.4.0",
"ipAddress": "203.0.113.10",
"createdAt": "2024-01-16T06:00:00.000Z"
}

Если slug неверный, ответ будет таким:

{
"message": "Monitor not found"
}