监控 API 参考

字段的可能取值

监控地区

取值说明
US_EAST_1北弗吉尼亚
CA_CENTRAL_1加拿大(蒙特利尔)
EU_CENTRAL_1法兰克福
AP_NORTHEAST_1东京

监控告警类型

取值说明
INCIDENT事件告警
EMAIL邮件告警
SMS短信告警
SLACKSlack 告警
DISCORDDiscord 告警
MICROSOFT_TEAMSMicrosoft Teams 告警
PHONE_CALL电话呼叫告警
WEBHOOKWebhook 告警
GOOGLE_CHATGoogle Chat 告警
WHATSAPPWhatsApp 告警

监控状态

取值说明
UP监控运行正常
DOWN监控出现故障
DEGRADED监控存在问题
UNKNOWN无法确定监控状态

监控运行状态

取值说明
ACTIVE监控会执行检测并发送告警
MUTED监控会执行检测,但不发送告警
PAUSED监控不执行检测

获取监控列表

你可以用这个端点查找并翻阅所有已有监控的列表。

端点:

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"
}

更新监控运行状态

和控制台中的状态菜单一样,你可以恢复、静音或暂停监控。静音的监控会继续检测,但不会发送告警、执行路由规则或通知订阅者。暂停的监控会停止检测,直到你将其改回 ACTIVE。

端点:

PUT /monitors/:id/state

请求体参数

参数类型说明
stateenum必填。新的运行状态 ('ACTIVE', 'MUTED', 'PAUSED')。
forMinutesnumber可选,仅适用于 MUTED。经过这么多分钟后自动解除静音,最多 10080(7 天)。省略时,监控会保持静音,直到你再次更改运行状态。

请求示例

{
"state": "MUTED",
"forMinutes": 60
}

响应示例

{
"id": "monitor-id-1",
"state": "MUTED",
"message": "Monitor state updated successfully."
}

获取监控列表返回的监控会在 active、muted 和 mutedUntil 字段中显示当前运行状态。暂停的监控为 active: false。静音的监控为 active: true 且 muted: true,mutedUntil 则是限时静音结束的时间。

删除监控

端点:

DELETE /monitors/:id

请求示例

DELETE /monitors/monitor-id-1

响应示例

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

获取监控日志

端点:

GET /monitors/:id/logs

查询参数

参数类型默认值说明
limitnumber100每页的条目数。不能超过 1000。
pagenumber1要获取的页码。
fromstring一年前仅返回该 ISO 8601 时间及之后的结果。最多可追溯一年。
tostringnull仅返回该 ISO 8601 时间及之前的结果。
monitorIdstring-监控的 ID。
locationstringnull监控的地区。
createdAtstring | object | numbernull创建日期。可以是字符串、数字,或带 gte 和 lte 字段的对象。
isSuccessfulbooleannull该次检测是否成功。
isSSLCheckbooleannull该次检测是否为 SSL 检测。
httpStatusCodestringnull响应的 HTTP 状态码。
status('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')null监控的状态。
dnsTimestring | number | objectnullDNS 解析耗时。
tcpTimestring | number | objectnullTCP 连接耗时。
tlsTimestring | number | objectnullTLS 握手耗时。
firstByteTimestring | number | objectnull收到首字节的耗时。
downloadTimestring | number | objectnull下载耗时。
responseTimestring | number | objectnull总响应时间。
performanceTimestring | number | objectnull性能耗时。
accessabilityScorestring | number | objectnull无障碍得分。
seoScorestring | number | objectnullSEO 得分。
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
}

获取监控的正常运行时间

监控在某个时间范围内的可用性和响应时间,并附有按天的明细。范围默认为最近 30 天,最长可达 395 天。超过五天的范围按整天计算,结束时间为午夜时会截止到前一天,因此 start=2026-10-01T00:00:00Z&end=2026-11-01T00:00:00Z 正好是整个 10 月。

端点:

GET /monitors/:id/summary

查询参数

参数类型默认值说明
startstring结束前 30 天范围的开始时间,ISO 8601 格式。
endstring现在范围的结束时间,ISO 8601 格式。

请求示例

GET /monitors/monitor-id-1/summary?start=2026-10-01T00:00:00Z&end=2026-11-01T00:00:00Z

响应示例

{
"monitorId": "monitor-id-1",
"start": "2026-10-01T00:00:00.000Z",
"end": "2026-10-31T23:59:59.999Z",
"firstCheckDay": "2026-09-12",
"availability": 99.95,
"checks": 8928,
"failedChecks": 4,
"downtimeSeconds": 720,
"avgResponseTime": 216,
"response95": null,
"avgDailyResponse95": 268,
"days": [
{
"date": "2026-10-01",
"availability": 100,
"checks": 288,
"failedChecks": 0,
"avgResponseTime": 212
}
]
}
  • availability 是成功检查所占的比例,范围内没有检查时为 null。
  • downtimeSeconds 是失败检查次数乘以检查间隔。
  • firstCheckDay 是监控有检查记录的第一天。如果它晚于 start,数据只涵盖从那天起的日子。
  • days 只列出有检查的日子。

按 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 ping 跟踪定时任务。产品配置和控制台用法见 Cron 监控。

字段的可能取值

Cron 监控状态

取值说明
UP监控运行正常
DOWN监控出现故障
DEGRADED监控存在问题
UNKNOWN无法确定监控状态

Cron 监控运行状态

取值说明
ACTIVE监控正在正常检测
PAUSED监控检测已暂停
MUTED监控已静音(不发送通知)

Cron 监控日志状态

取值说明
SUCCESS任务成功完成
FAILURE任务显式上报了失败
MISSED任务未在预期时间窗口内 ping
LATE任务在周期之后、宽限期之内 ping
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。用它来拼接任务的 ping URL。第一次成功的 ping 会安排后台检查任务。

更新 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
}
}

Ping 端点

这些端点不需要认证。监控的 slug 本身就充当密钥。

你可以通过 API 基础 URL 或专用的 cron 主机发送 ping:

  • 成功: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

任务每次按计划完成时发送一次成功 ping。若要记录执行时长,请在任务运行前发送开始 ping,在结束时发送成功或失败 ping。

成功 ping 示例

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"
}