monitoring
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCheckly Monitoring
Checkly 监控
- Refer to docs for Checkly CLI v6.0.0 and above.
- Check the Checkly CLI output to figure out into which folder the setup was generated.
- Use the Checkly CLI reference documentation.
- Use the Checkly construct reference documentation.
- Import and / or require any constructs you need in your code, such as ,
ApiCheck, orBrowserCheckfrom thePlaywrightCheckpackage.checkly/constructs - Always ground generated code and CLI commands against the official documentation and examples in this file.
- 请参考Checkly CLI v6.0.0及以上版本的文档。
- 查看Checkly CLI输出结果,确定安装生成的文件所在的文件夹。
- 使用Checkly CLI参考文档。
- 使用Checkly构造器参考文档。
- 在代码中导入或引入所需的构造器,例如从包中导入
checkly/constructs、ApiCheck或BrowserCheck。PlaywrightCheck - 生成的代码和CLI命令请始终以本文档中的官方文档和示例为准。
Installing the Checkly CLI
安装Checkly CLI
- ALWAYS use .
npm create checkly@latest - NEVER make up commands that do not exist.
- 请始终使用命令。
npm create checkly@latest - 切勿编造不存在的命令。
Project Structure
项目结构
- - Mandatory global project and CLI configuration. We recommend using TypeScript.
checkly.config.ts - - TS / JS files that define the checks.
*.check.ts|js - - TS / JS files that contain Playwright code for Browser and MultiStep checks.
*.spec.ts|js - - Default directory where all your checks are stored. Use this directory if it already exists, otherwise create a new directory for your checks.
src/__checks__ - - Standard NPM project manifest.
package.json
Here is an example directory tree of what that would look like:
.
|-- checkly.config.ts
|-- package.json
-- checks
|-- alert-channels.ts
|-- api-check.check.ts
`-- homepage.spec.ts
-- src The at the root of your project defines a range of defaults for all your checks.
checkly.config.tstypescript
import { defineConfig } from 'checkly'
import { Frequency } from 'checkly/constructs'
export default defineConfig({
projectName: "Production Monitoring Suite",
logicalId: "prod-monitoring-2025",
repoUrl: "https://github.com/acme/monitoring",
checks: {
activated: true,
muted: false,
runtimeId: "2025.04",
frequency: Frequency.EVERY_10M,
locations: ["us-east-1", "eu-west-1", "ap-southeast-1"],
tags: ["production", "critical"],
checkMatch: "**/__checks__/*.check.ts",
ignoreDirectoriesMatch: ["node_modules/**", "dist/**"],
playwrightConfig: {
use: {
baseURL: "https://app.example.com",
},
},
browserChecks: {
frequency: Frequency.EVERY_30M,
testMatch: "**/__tests__/*.spec.ts",
},
},
cli: {
runLocation: "eu-west-1",
privateRunLocation: "private-dc1",
retries: 2,
},
})- - 必须的全局项目及CLI配置文件。我们推荐使用TypeScript。
checkly.config.ts - - 定义检查项的TS/JS文件。
*.check.ts|js - - 包含Browser检查和MultiStep检查所需Playwright代码的TS/JS文件。
*.spec.ts|js - - 存储所有检查项的默认目录。如果该目录已存在,请使用它;否则请新建一个检查项目录。
src/__checks__ - - 标准NPM项目清单文件。
package.json
以下是一个示例目录结构:
.
|-- checkly.config.ts
|-- package.json
-- checks
|-- alert-channels.ts
|-- api-check.check.ts
`-- homepage.spec.ts
-- src 项目根目录下的定义了所有检查项的一系列默认配置。
checkly.config.tstypescript
import { defineConfig } from 'checkly'
import { Frequency } from 'checkly/constructs'
export default defineConfig({
projectName: "Production Monitoring Suite",
logicalId: "prod-monitoring-2025",
repoUrl: "https://github.com/acme/monitoring",
checks: {
activated: true,
muted: false,
runtimeId: "2025.04",
frequency: Frequency.EVERY_10M,
locations: ["us-east-1", "eu-west-1", "ap-southeast-1"],
tags: ["production", "critical"],
checkMatch: "**/__checks__/*.check.ts",
ignoreDirectoriesMatch: ["node_modules/**", "dist/**"],
playwrightConfig: {
use: {
baseURL: "https://app.example.com",
},
},
browserChecks: {
frequency: Frequency.EVERY_30M,
testMatch: "**/__tests__/*.spec.ts",
},
},
cli: {
runLocation: "eu-west-1",
privateRunLocation: "private-dc1",
retries: 2,
},
})Check and Monitor Constructs
检查与监控构造器
API Check
API检查
- Import the construct from
ApiCheck.checkly/constructs - When adding , always use
assertionsclass for API Checks.AssertionBuilder - When referencing environment variables always use the handlebar syntax .
{{MY_ENV_VAR}} - When referencing secrets always use the handlebar syntax .
{{MY_SECRET}} - If endpoints require authentication ask the user which authentication method to use and then generate a setupScript to authenticate the given requests.
- Referenced and
setupScript.tsfor API checks must be plain ts files and not export anything.teardownScript.ts - Check in the code if API endpoints require authentication.
typescript
import { AlertEscalationBuilder, ApiCheck, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new ApiCheck('example-api-check', {
name: 'Example API Check',
request: {
url: 'https://api.example.com/v1/products',
method: 'GET',
ipFamily: 'IPv4',
},
setupScript: {
entrypoint: './setup-script.ts',
},
tearDownScript: {
entrypoint: './teardown-script.ts',
},
degradedResponseTime: 5000,
maxResponseTime: 20000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_5M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})- 从中导入
checkly/constructs构造器。ApiCheck - 添加断言时,请始终为API检查使用类。
AssertionBuilder - 引用环境变量时,请始终使用handlebar语法。
{{MY_ENV_VAR}} - 引用密钥时,请始终使用handlebar语法。
{{MY_SECRET}} - 如果端点需要认证,请询问用户使用哪种认证方式,然后生成一个setupScript来对指定请求进行认证。
- API检查中引用的和
setupScript.ts必须是纯TS文件,不能导出任何内容。teardownScript.ts - 检查代码中API端点是否需要认证。
typescript
import { AlertEscalationBuilder, ApiCheck, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new ApiCheck('example-api-check', {
name: 'Example API Check',
request: {
url: 'https://api.example.com/v1/products',
method: 'GET',
ipFamily: 'IPv4',
},
setupScript: {
entrypoint: './setup-script.ts',
},
tearDownScript: {
entrypoint: './teardown-script.ts',
},
degradedResponseTime: 5000,
maxResponseTime: 20000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_5M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})Authentication Setup Scripts for API Checks
API检查的认证设置脚本
- Setup scripts should be flat scripts, no functions, no exports, they will be executed straight by Checkly.
- Use axios for making HTTP requests.
- Read the input credentials from env variables using .
process.env - Pass auth tokens to the request object using .
request.headers['key'] = AUTH_TOKEN_VALUE
- 设置脚本应为扁平脚本,无函数、无导出,将由Checkly直接执行。
- 使用axios发送HTTP请求。
- 使用从环境变量中读取输入凭证。
process.env - 使用将认证令牌传递给请求对象。
request.headers['key'] = AUTH_TOKEN_VALUE
Browser Check
浏览器检查
- Import the construct from
BrowserCheck.checkly/constructs - Generate a separate file for the Playwright code referenced in the
.spec.tsconstruct.BrowserCheck - Use the property to specify the path to your Playwright test file.
code.entrypoint
typescript
import { AlertEscalationBuilder, BrowserCheck, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new BrowserCheck('example-browser-check', {
name: 'Example Browser Check',
code: {
entrypoint: './example-browser-check.spec.ts',
},
activated: false,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_10M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})- 从中导入
checkly/constructs构造器。BrowserCheck - 为构造器中引用的Playwright代码生成单独的
BrowserCheck文件。.spec.ts - 使用属性指定Playwright测试文件的路径。
code.entrypoint
typescript
import { AlertEscalationBuilder, BrowserCheck, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new BrowserCheck('example-browser-check', {
name: 'Example Browser Check',
code: {
entrypoint: './example-browser-check.spec.ts',
},
activated: false,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_10M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})Playwright Check Suite
Playwright检查套件
- Import the construct from
PlaywrightCheck.checkly/constructs - use if your tasked to reuse a Playwright project.
pwProjects
typescript
import { PlaywrightCheck } from "checkly/constructs"
const playwrightChecks = new PlaywrightCheck("multi-browser-check", {
name: "Multi-browser check suite",
playwrightConfigPath: "./playwright.config.ts",
// Playwright Check Suites support all browsers
// defined in your `playwright.config`
pwProjects: ["chromium", "firefox", "webkit"],
});- 从中导入
checkly/constructs构造器。PlaywrightCheck - 如果需要复用Playwright项目,请使用。
pwProjects
typescript
import { PlaywrightCheck } from "checkly/constructs"
const playwrightChecks = new PlaywrightCheck("multi-browser-check", {
name: "Multi-browser check suite",
playwrightConfigPath: "./playwright.config.ts",
// Playwright Check Suites support all browsers
// defined in your `playwright.config`
pwProjects: ["chromium", "firefox", "webkit"],
});MultiStep Check
多步骤检查
- Import the construct from
MultiStepCheck.checkly/constructs - Generate a separate file for the Playwright code referenced in the
.spec.tsconstruct.MultiStepCheck - Use the property to specify the path to your Playwright test file.
code.entrypoint
typescript
import { AlertEscalationBuilder, Frequency, MultiStepCheck, RetryStrategyBuilder } from 'checkly/constructs'
new MultiStepCheck('example-multi-step-check', {
name: 'Example Multistep Check',
code: {
entrypoint: './example-multistep-check.spec.ts',
},
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_1H,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.noRetries(),
runParallel: true,
})- 从中导入
checkly/constructs构造器。MultiStepCheck - 为构造器中引用的Playwright代码生成单独的
MultiStepCheck文件。.spec.ts - 使用属性指定Playwright测试文件的路径。
code.entrypoint
typescript
import { AlertEscalationBuilder, Frequency, MultiStepCheck, RetryStrategyBuilder } from 'checkly/constructs'
new MultiStepCheck('example-multi-step-check', {
name: 'Example Multistep Check',
code: {
entrypoint: './example-multistep-check.spec.ts',
},
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_1H,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.noRetries(),
runParallel: true,
})TCP Monitor
TCP监控
- Import the construct from
TcpMonitor.checkly/constructs - When adding , always use
assertionsclass for TCP monitors.TcpAssertionBuilder
typescript
import { AlertEscalationBuilder, Frequency, RetryStrategyBuilder, TcpAssertionBuilder, TcpMonitor } from 'checkly/constructs'
new TcpMonitor('example-tcp-monitor', {
name: 'Example TCP Monitor',
request: {
hostname: 'tcp.example.com',
port: 4242,
ipFamily: 'IPv4',
assertions: [
TcpAssertionBuilder.responseTime().lessThan(200),
TcpAssertionBuilder.responseData().isEmpty(),
],
},
degradedResponseTime: 5000,
maxResponseTime: 5000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_1H,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})- 从中导入
checkly/constructs构造器。TcpMonitor - 添加断言时,请始终为TCP监控使用类。
TcpAssertionBuilder
typescript
import { AlertEscalationBuilder, Frequency, RetryStrategyBuilder, TcpAssertionBuilder, TcpMonitor } from 'checkly/constructs'
new TcpMonitor('example-tcp-monitor', {
name: 'Example TCP Monitor',
request: {
hostname: 'tcp.example.com',
port: 4242,
ipFamily: 'IPv4',
assertions: [
TcpAssertionBuilder.responseTime().lessThan(200),
TcpAssertionBuilder.responseData().isEmpty(),
],
},
degradedResponseTime: 5000,
maxResponseTime: 5000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_1H,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})URL Monitor
URL监控
- Import the construct from
UrlMonitor.checkly/constructs - When adding , always use
assertions.UrlAssertionBuilder
typescript
import { AlertEscalationBuilder, Frequency, RetryStrategyBuilder, UrlAssertionBuilder, UrlMonitor } from 'checkly/constructs'
new UrlMonitor('example-url-monitor', {
name: 'Example URL Monitor',
request: {
url: 'https://example.com',
ipFamily: 'IPv4',
assertions: [
UrlAssertionBuilder.statusCode().equals(200),
],
},
degradedResponseTime: 5000,
maxResponseTime: 20000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_5M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})- 从中导入
checkly/constructs构造器。UrlMonitor - 添加断言时,请始终使用。
UrlAssertionBuilder
typescript
import { AlertEscalationBuilder, Frequency, RetryStrategyBuilder, UrlAssertionBuilder, UrlMonitor } from 'checkly/constructs'
new UrlMonitor('example-url-monitor', {
name: 'Example URL Monitor',
request: {
url: 'https://example.com',
ipFamily: 'IPv4',
assertions: [
UrlAssertionBuilder.statusCode().equals(200),
],
},
degradedResponseTime: 5000,
maxResponseTime: 20000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-west-2',
],
frequency: Frequency.EVERY_5M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})DNS Monitor
DNS监控
- Import the construct from
DnsMonitor.checkly/constructs - Reference the docs for DNS monitors before generating any code.
- When adding , always use
assertionsclass.DnsAssertionBuilder
typescript
import { AlertEscalationBuilder, DnsAssertionBuilder, DnsMonitor, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new DnsMonitor('example-dns-monitor', {
name: 'Example DNS Monitor',
request: {
recordType: 'AAAA',
query: 'welcome.checklyhq.com',
assertions: [
DnsAssertionBuilder.responseCode().equals('NOERROR'),
],
},
degradedResponseTime: 500,
maxResponseTime: 1000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-north-1',
],
frequency: Frequency.EVERY_10M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.noRetries(),
runParallel: false,
})- 从中导入
checkly/constructs构造器。DnsMonitor - 生成任何代码前,请参考DNS监控文档。
- 添加断言时,请始终使用类。
DnsAssertionBuilder
typescript
import { AlertEscalationBuilder, DnsAssertionBuilder, DnsMonitor, Frequency, RetryStrategyBuilder } from 'checkly/constructs'
new DnsMonitor('example-dns-monitor', {
name: 'Example DNS Monitor',
request: {
recordType: 'AAAA',
query: 'welcome.checklyhq.com',
assertions: [
DnsAssertionBuilder.responseCode().equals('NOERROR'),
],
},
degradedResponseTime: 500,
maxResponseTime: 1000,
activated: true,
muted: false,
shouldFail: false,
locations: [
'eu-central-1',
'eu-north-1',
],
frequency: Frequency.EVERY_10M,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.noRetries(),
runParallel: false,
})Heartbeat Monitor
心跳监控
- Import the construct from
HeartbeatMonitor.checkly/constructs
typescript
import { AlertEscalationBuilder, Frequency, HeartbeatMonitor, RetryStrategyBuilder } from 'checkly/constructs'
new HeartbeatMonitor('example-heartbeat-monitor', {
name: 'Example Heartbeat Monitor',
period: 1,
periodUnit: 'hours',
grace: 30,
graceUnit: 'minutes',
activated: true,
muted: false,
shouldFail: false,
frequency: Frequency.EVERY_10S,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})- 从中导入
checkly/constructs构造器。HeartbeatMonitor
typescript
import { AlertEscalationBuilder, Frequency, HeartbeatMonitor, RetryStrategyBuilder } from 'checkly/constructs'
new HeartbeatMonitor('example-heartbeat-monitor', {
name: 'Example Heartbeat Monitor',
period: 1,
periodUnit: 'hours',
grace: 30,
graceUnit: 'minutes',
activated: true,
muted: false,
shouldFail: false,
frequency: Frequency.EVERY_10S,
alertEscalationPolicy: AlertEscalationBuilder.runBasedEscalation(1, {
amount: 0,
interval: 5,
}, {
enabled: false,
percentage: 10,
}),
retryStrategy: RetryStrategyBuilder.linearStrategy({
baseBackoffSeconds: 60,
maxRetries: 2,
maxDurationSeconds: 600,
sameRegion: true,
}),
runParallel: true,
})Check Group
检查组
- Import the construct from
CheckGroupV2.checkly/constructs - Check Groups are used to group checks together for easier management and organization.
- Checks are added to Check Groups by referencing the group in the property of a check.
group
typescript
import { CheckGroupV2 } from 'checkly/constructs'
export const exampleGroup = new CheckGroupV2('example-group', {
name: 'Example Group',
})- 从中导入
checkly/constructs构造器。CheckGroupV2 - 检查组用于将检查项分组,便于管理和组织。
- 通过在检查项的属性中引用组,将检查项添加到检查组。
group
typescript
import { CheckGroupV2 } from 'checkly/constructs'
export const exampleGroup = new CheckGroupV2('example-group', {
name: 'Example Group',
})Alert Channel Constructs
告警通道构造器
- Alert channels are used to send notifications when checks and monitors fail or recover.
- Alert channels are added to checks, monitors, and check groups constructs by adding them to the array property.
alertChannels
Here are some examples of how to create different types of alert channels. All alert are described in the Checkly docs.
- 告警通道用于在检查和监控失败或恢复时发送通知。
- 通过将告警通道添加到数组属性,可将其关联到检查项、监控项和检查组构造器。
alertChannels
以下是创建不同类型告警通道的示例。所有告警通道的描述请参考Checkly文档。
Email Alert Channel
邮件告警通道
typescript
import { EmailAlertChannel } from 'checkly/constructs'
export const testEmailAlert = new EmailAlertChannel('example-email-alert-channel', {
address: 'test@example.com',
sslExpiry: true,
})typescript
import { EmailAlertChannel } from 'checkly/constructs'
export const testEmailAlert = new EmailAlertChannel('example-email-alert-channel', {
address: 'test@example.com',
sslExpiry: true,
})Phone Call Alert Channel
电话告警通道
typescript
import { PhoneCallAlertChannel } from 'checkly/constructs'
export const testUserPhoneCallAlert = new PhoneCallAlertChannel('example-call-alert-channel', {
name: 'Test User',
phoneNumber: '+311234567890',
})typescript
import { PhoneCallAlertChannel } from 'checkly/constructs'
export const testUserPhoneCallAlert = new PhoneCallAlertChannel('example-call-alert-channel', {
name: 'Test User',
phoneNumber: '+311234567890',
})Slack Alert Channel
Slack告警通道
typescript
import { SlackAlertChannel } from 'checkly/constructs'
export const generalSlackAlert = new SlackAlertChannel('example-slack-alert-channel', {
url: 'https://hooks.slack.com/services/TK123456789123/12345/123456789',
channel: '#general',
})typescript
import { SlackAlertChannel } from 'checkly/constructs'
export const generalSlackAlert = new SlackAlertChannel('example-slack-alert-channel', {
url: 'https://hooks.slack.com/services/TK123456789123/12345/123456789',
channel: '#general',
})Supporting Constructs
辅助构造器
Status Page
状态页面
- Import the construct from
StatusPage.checkly/constructs - Status pages are used to display the status of your services to your users.
- A Status Page consists of cards which include Status Page Services.
typescript
import { StatusPage } from 'checkly/constructs'
import { exampleService } from './services/example-service.check'
new StatusPage('example-status-page', {
name: 'Example Status Page',
url: 'example-status-page',
cards: [
{
name: 'Example service',
services: [
exampleService,
],
},
],
customDomain: 'status.example.com',
defaultTheme: 'AUTO',
})- 从中导入
checkly/constructs构造器。StatusPage - 状态页面用于向用户展示服务的状态。
- 状态页面由包含状态页面服务的卡片组成。
typescript
import { StatusPage } from 'checkly/constructs'
import { exampleService } from './services/example-service.check'
new StatusPage('example-status-page', {
name: 'Example Status Page',
url: 'example-status-page',
cards: [
{
name: 'Example service',
services: [
exampleService,
],
},
],
customDomain: 'status.example.com',
defaultTheme: 'AUTO',
})Status Page Service
状态页面服务
- Import the construct from
StatusPageService.checkly/constructs - Status Page Services are used to represent individual services on a Status Page.
typescript
import { StatusPageService } from 'checkly/constructs'
export const exampleService = new StatusPageService('example-status-page-service', {
name: 'Example Service',
})- 从中导入
checkly/constructs构造器。StatusPageService - 状态页面服务用于在状态页面上表示单个服务。
typescript
import { StatusPageService } from 'checkly/constructs'
export const exampleService = new StatusPageService('example-status-page-service', {
name: 'Example Service',
})Dashboard
仪表板
- Import the construct from
Dashboard.checkly/constructs - Dashboards are used to display the results of your checks on screens external to Checkly.
typescript
import { Dashboard } from 'checkly/constructs'
new Dashboard('example-dashboard', {
tags: [
'app:webshop',
],
customUrl: 'example-dashboard',
customDomain: 'dash.example.com',
header: 'Example Dashboard',
description: 'Example dashboard',
width: 'FULL',
refreshRate: 60,
paginate: true,
paginationRate: 60,
checksPerPage: 15,
useTagsAndOperator: false,
hideTags: false,
enableIncidents: false,
expandChecks: false,
showHeader: true,
isPrivate: false,
showP95: true,
showP99: true,
})- 从中导入
checkly/constructs构造器。Dashboard - 仪表板用于在Checkly外部的屏幕上展示检查结果。
typescript
import { Dashboard } from 'checkly/constructs'
new Dashboard('example-dashboard', {
tags: [
'app:webshop',
],
customUrl: 'example-dashboard',
customDomain: 'dash.example.com',
header: 'Example Dashboard',
description: 'Example dashboard',
width: 'FULL',
refreshRate: 60,
paginate: true,
paginationRate: 60,
checksPerPage: 15,
useTagsAndOperator: false,
hideTags: false,
enableIncidents: false,
expandChecks: false,
showHeader: true,
isPrivate: false,
showP95: true,
showP99: true,
})Maintenance Window
维护窗口
- Import the construct from
MaintenanceWindow.checkly/constructs - Maintenance windows are used to pause checks during maintenance periods so no alerts are sent.
- Checks are referenced by their tags in the property.
tags
typescript
import { MaintenanceWindow } from 'checkly/constructs'
new MaintenanceWindow('example-maintenance-window', {
name: 'Example Maintenance Window',
tags: [
'app:webshop',
],
startsAt: new Date('2025-07-01T09:00:00.000Z'),
endsAt: new Date('2025-07-01T10:00:00.000Z'),
repeatInterval: 1,
repeatUnit: 'WEEK',
repeatEndsAt: new Date('2025-08-01T00:00:00.000Z'),
})- 从中导入
checkly/constructs构造器。MaintenanceWindow - 维护窗口用于在维护期间暂停检查,避免发送告警。
- 在属性中通过标签引用检查项。
tags
typescript
import { MaintenanceWindow } from 'checkly/constructs'
new MaintenanceWindow('example-maintenance-window', {
name: 'Example Maintenance Window',
tags: [
'app:webshop',
],
startsAt: new Date('2025-07-01T09:00:00.000Z'),
endsAt: new Date('2025-07-01T10:00:00.000Z'),
repeatInterval: 1,
repeatUnit: 'WEEK',
repeatEndsAt: new Date('2025-08-01T00:00:00.000Z'),
})Private Location
私有位置
- Import the construct from
PrivateLocation.checkly/constructs - Private locations are used to run checks from your own infrastructure with the Checkly Agent, an OCI compatible container.
typescript
import { PrivateLocation } from 'checkly/constructs'
export const examplePrivateLocation = new PrivateLocation('example-private-location', {
name: 'Example Private Location',
slugName: 'example-private-location',
icon: 'location',
})- 从中导入
checkly/constructs构造器。PrivateLocation - 私有位置用于通过Checkly Agent(兼容OCI的容器)在您自己的基础设施上运行检查。
typescript
import { PrivateLocation } from 'checkly/constructs'
export const examplePrivateLocation = new PrivateLocation('example-private-location', {
name: 'Example Private Location',
slugName: 'example-private-location',
icon: 'location',
})Testing and Debugging
测试与调试
- Test checks using command pass env variables using
npx checkly testparam, use-eto persist results and--recordto be able to see all errors--verbose
- 使用命令测试检查项,使用
npx checkly test参数传递环境变量,使用-e参数保存结果,使用--record参数查看所有错误信息--verbose