@openstatus/sdk-node 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +444 -134
- package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts +36 -36
- package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -1
- package/esm/gen/openstatus/monitor/v1/monitor_pb.js +37 -37
- package/esm/gen/openstatus/monitor/v1/service_pb.d.ts +156 -0
- package/esm/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -1
- package/esm/gen/openstatus/monitor/v1/service_pb.js +43 -13
- package/esm/gen/openstatus/status_report/v1/service_pb.d.ts +357 -0
- package/esm/gen/openstatus/status_report/v1/service_pb.d.ts.map +1 -0
- package/esm/gen/openstatus/status_report/v1/service_pb.js +79 -0
- package/esm/gen/openstatus/status_report/v1/status_report_pb.d.ts +182 -0
- package/esm/gen/openstatus/status_report/v1/status_report_pb.d.ts.map +1 -0
- package/esm/gen/openstatus/status_report/v1/status_report_pb.js +55 -0
- package/esm/mod.d.ts +43 -12
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +24 -11
- package/package.json +1 -1
- package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts +36 -36
- package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -1
- package/script/gen/openstatus/monitor/v1/monitor_pb.js +37 -37
- package/script/gen/openstatus/monitor/v1/service_pb.d.ts +156 -0
- package/script/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -1
- package/script/gen/openstatus/monitor/v1/service_pb.js +44 -14
- package/script/gen/openstatus/status_report/v1/service_pb.d.ts +357 -0
- package/script/gen/openstatus/status_report/v1/service_pb.d.ts.map +1 -0
- package/script/gen/openstatus/status_report/v1/service_pb.js +82 -0
- package/script/gen/openstatus/status_report/v1/status_report_pb.d.ts +182 -0
- package/script/gen/openstatus/status_report/v1/status_report_pb.d.ts.map +1 -0
- package/script/gen/openstatus/status_report/v1/status_report_pb.js +58 -0
- package/script/mod.d.ts +43 -12
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +31 -14
package/README.md
CHANGED
|
@@ -1,68 +1,83 @@
|
|
|
1
|
-
# OpenStatus Node.js SDK
|
|
1
|
+
# OpenStatus Node.js SDK (Beta)
|
|
2
2
|
|
|
3
|
-
[](https://jsr.io/@openstatus/sdk-node)
|
|
4
|
+
[](https://www.npmjs.com/package/@openstatus/sdk-node)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
|
-
Official Node.js SDK for [OpenStatus](https://openstatus.dev) -
|
|
8
|
-
monitoring platform.
|
|
7
|
+
Official Node.js SDK for [OpenStatus](https://openstatus.dev) - The open-source status page with uptime monitoring.
|
|
9
8
|
|
|
10
9
|
## Features
|
|
11
10
|
|
|
11
|
+
### Status Page
|
|
12
|
+
- **Status Reports** - Manage incident and maintenance reports with update timelines
|
|
13
|
+
|
|
14
|
+
### Monitoring
|
|
12
15
|
- **HTTP Monitoring** - Monitor websites and APIs with customizable assertions
|
|
13
16
|
- **TCP Monitoring** - Check database connections and other TCP services
|
|
14
17
|
- **DNS Monitoring** - Verify DNS records and resolution
|
|
18
|
+
|
|
15
19
|
- **Global Regions** - Monitor from 28 locations worldwide
|
|
16
|
-
- **Type-safe** - Full TypeScript support with generated types
|
|
20
|
+
- **Type-safe** - Full TypeScript support with generated types from protobuf
|
|
17
21
|
|
|
18
22
|
## Installation
|
|
19
23
|
|
|
20
24
|
### JSR
|
|
21
25
|
|
|
22
26
|
```bash
|
|
23
|
-
npx jsr add @openstatus/node
|
|
27
|
+
npx jsr add @openstatus/sdk-node
|
|
24
28
|
```
|
|
25
29
|
|
|
26
30
|
### npm
|
|
27
31
|
|
|
28
32
|
```bash
|
|
29
|
-
npm install @openstatus/node
|
|
33
|
+
npm install @openstatus/sdk-node
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
### Deno
|
|
33
37
|
|
|
34
38
|
```typescript
|
|
35
|
-
import { openstatus } from "jsr:@openstatus/node
|
|
39
|
+
import { openstatus } from "jsr:@openstatus/sdk-node";
|
|
36
40
|
```
|
|
37
41
|
|
|
38
42
|
## Quick Start
|
|
39
43
|
|
|
40
44
|
```typescript
|
|
41
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
HTTPMethod,
|
|
47
|
+
NumberComparator,
|
|
48
|
+
openstatus,
|
|
49
|
+
Periodicity,
|
|
50
|
+
Region,
|
|
51
|
+
} from "@openstatus/sdk-node";
|
|
42
52
|
|
|
43
53
|
const headers = {
|
|
44
|
-
"x-openstatus-key":
|
|
54
|
+
"x-openstatus-key": `${process.env.OPENSTATUS_API_KEY}`,
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
// Create a monitor
|
|
48
|
-
const monitor = await openstatus.monitor.v1.MonitorService
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
58
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService
|
|
59
|
+
.createHTTPMonitor(
|
|
60
|
+
{
|
|
61
|
+
monitor: {
|
|
62
|
+
name: "My API",
|
|
63
|
+
url: "https://api.example.com/health",
|
|
64
|
+
periodicity: Periodicity.PERIODICITY_1M,
|
|
65
|
+
method: HTTPMethod.HTTP_METHOD_GET,
|
|
66
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.FLY_SYD],
|
|
67
|
+
active: true,
|
|
68
|
+
statusCodeAssertions: [
|
|
69
|
+
{ comparator: NumberComparator.EQUAL, target: BigInt(200) },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{ headers },
|
|
74
|
+
);
|
|
60
75
|
|
|
61
|
-
console.log(`Monitor created: ${monitor
|
|
76
|
+
console.log(`Monitor created: ${monitor?.id}`);
|
|
62
77
|
|
|
63
78
|
// List all monitors
|
|
64
|
-
const { httpMonitors, tcpMonitors, dnsMonitors, totalSize } =
|
|
65
|
-
|
|
79
|
+
const { httpMonitors, tcpMonitors, dnsMonitors, totalSize } = await openstatus
|
|
80
|
+
.monitor.v1.MonitorService.listMonitors({}, { headers });
|
|
66
81
|
|
|
67
82
|
console.log(`Found ${totalSize} monitors`);
|
|
68
83
|
```
|
|
@@ -74,7 +89,7 @@ All API requests require an API key. Get yours from the
|
|
|
74
89
|
|
|
75
90
|
```typescript
|
|
76
91
|
const headers = {
|
|
77
|
-
"x-openstatus-key":
|
|
92
|
+
"x-openstatus-key": `${process.env.OPENSTATUS_API_KEY}`,
|
|
78
93
|
};
|
|
79
94
|
|
|
80
95
|
// Pass headers to any service method
|
|
@@ -97,15 +112,37 @@ await openstatus.monitor.v1.MonitorService.listMonitors({}, { headers });
|
|
|
97
112
|
Create an HTTP/HTTPS monitor.
|
|
98
113
|
|
|
99
114
|
```typescript
|
|
115
|
+
import { HTTPMethod, Periodicity, Region } from "@openstatus/sdk-node";
|
|
116
|
+
|
|
100
117
|
const { monitor } = await openstatus.monitor.v1.MonitorService
|
|
101
118
|
.createHTTPMonitor(
|
|
102
119
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
monitor: {
|
|
121
|
+
name: "My Website",
|
|
122
|
+
url: "https://example.com",
|
|
123
|
+
periodicity: Periodicity.PERIODICITY_1M,
|
|
124
|
+
method: HTTPMethod.HTTP_METHOD_GET,
|
|
125
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.FLY_SYD],
|
|
126
|
+
active: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{ headers },
|
|
130
|
+
);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### `updateHTTPMonitor(request, options)`
|
|
134
|
+
|
|
135
|
+
Update an existing HTTP monitor.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService
|
|
139
|
+
.updateHTTPMonitor(
|
|
140
|
+
{
|
|
141
|
+
id: "mon_123",
|
|
142
|
+
monitor: {
|
|
143
|
+
name: "Updated Name",
|
|
144
|
+
active: false,
|
|
145
|
+
},
|
|
109
146
|
},
|
|
110
147
|
{ headers },
|
|
111
148
|
);
|
|
@@ -118,11 +155,29 @@ Create a TCP connection monitor.
|
|
|
118
155
|
```typescript
|
|
119
156
|
const { monitor } = await openstatus.monitor.v1.MonitorService.createTCPMonitor(
|
|
120
157
|
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
158
|
+
monitor: {
|
|
159
|
+
name: "Database",
|
|
160
|
+
uri: "db.example.com:5432",
|
|
161
|
+
periodicity: Periodicity.PERIODICITY_5M,
|
|
162
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD],
|
|
163
|
+
active: true,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{ headers },
|
|
167
|
+
);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### `updateTCPMonitor(request, options)`
|
|
171
|
+
|
|
172
|
+
Update an existing TCP monitor.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.updateTCPMonitor(
|
|
176
|
+
{
|
|
177
|
+
id: "mon_123",
|
|
178
|
+
monitor: {
|
|
179
|
+
name: "Updated Database Monitor",
|
|
180
|
+
},
|
|
126
181
|
},
|
|
127
182
|
{ headers },
|
|
128
183
|
);
|
|
@@ -133,18 +188,40 @@ const { monitor } = await openstatus.monitor.v1.MonitorService.createTCPMonitor(
|
|
|
133
188
|
Create a DNS resolution monitor.
|
|
134
189
|
|
|
135
190
|
```typescript
|
|
191
|
+
import { RecordComparator } from "@openstatus/sdk-node";
|
|
192
|
+
|
|
136
193
|
const { monitor } = await openstatus.monitor.v1.MonitorService.createDNSMonitor(
|
|
137
194
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
195
|
+
monitor: {
|
|
196
|
+
name: "DNS Check",
|
|
197
|
+
uri: "example.com",
|
|
198
|
+
periodicity: Periodicity.PERIODICITY_10M,
|
|
199
|
+
regions: [Region.FLY_AMS],
|
|
200
|
+
active: true,
|
|
201
|
+
recordAssertions: [
|
|
202
|
+
{
|
|
203
|
+
record: "A",
|
|
204
|
+
comparator: RecordComparator.EQUAL,
|
|
205
|
+
target: "93.184.216.34",
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{ headers },
|
|
211
|
+
);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `updateDNSMonitor(request, options)`
|
|
215
|
+
|
|
216
|
+
Update an existing DNS monitor.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.updateDNSMonitor(
|
|
220
|
+
{
|
|
221
|
+
id: "mon_123",
|
|
222
|
+
monitor: {
|
|
223
|
+
name: "Updated DNS Check",
|
|
224
|
+
},
|
|
148
225
|
},
|
|
149
226
|
{ headers },
|
|
150
227
|
);
|
|
@@ -167,7 +244,7 @@ const { httpMonitors, tcpMonitors, dnsMonitors, nextPageToken, totalSize } =
|
|
|
167
244
|
Trigger an immediate check.
|
|
168
245
|
|
|
169
246
|
```typescript
|
|
170
|
-
await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
247
|
+
const { success } = await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
171
248
|
{ id: "mon_123" },
|
|
172
249
|
{ headers },
|
|
173
250
|
);
|
|
@@ -178,7 +255,7 @@ await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
|
178
255
|
Delete a monitor.
|
|
179
256
|
|
|
180
257
|
```typescript
|
|
181
|
-
await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
258
|
+
const { success } = await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
182
259
|
{ id: "mon_123" },
|
|
183
260
|
{ headers },
|
|
184
261
|
);
|
|
@@ -189,16 +266,19 @@ await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
|
189
266
|
Get the current status of a monitor across all configured regions.
|
|
190
267
|
|
|
191
268
|
```typescript
|
|
192
|
-
|
|
193
|
-
|
|
269
|
+
import { MonitorStatus, Region } from "@openstatus/sdk-node";
|
|
270
|
+
|
|
271
|
+
const { id, regions } = await openstatus.monitor.v1.MonitorService
|
|
272
|
+
.getMonitorStatus(
|
|
194
273
|
{ id: "mon_123" },
|
|
195
274
|
{ headers },
|
|
196
275
|
);
|
|
197
276
|
|
|
198
277
|
// regions is an array of { region, status }
|
|
199
|
-
//
|
|
278
|
+
// region: Region enum value (e.g., Region.FLY_AMS)
|
|
279
|
+
// status: MonitorStatus.ACTIVE, MonitorStatus.DEGRADED, or MonitorStatus.ERROR
|
|
200
280
|
for (const { region, status } of regions) {
|
|
201
|
-
console.log(`${region}: ${status}`);
|
|
281
|
+
console.log(`${Region[region]}: ${MonitorStatus[status]}`);
|
|
202
282
|
}
|
|
203
283
|
```
|
|
204
284
|
|
|
@@ -207,12 +287,12 @@ for (const { region, status } of regions) {
|
|
|
207
287
|
Get aggregated metrics and latency percentiles for a monitor.
|
|
208
288
|
|
|
209
289
|
```typescript
|
|
210
|
-
import { TimeRange } from "@openstatus/node
|
|
290
|
+
import { TimeRange } from "@openstatus/sdk-node";
|
|
211
291
|
|
|
212
292
|
const summary = await openstatus.monitor.v1.MonitorService.getMonitorSummary(
|
|
213
293
|
{
|
|
214
294
|
id: "mon_123",
|
|
215
|
-
timeRange: TimeRange.TIME_RANGE_7D, //
|
|
295
|
+
timeRange: TimeRange.TIME_RANGE_7D, // TIME_RANGE_1D, TIME_RANGE_7D, or TIME_RANGE_14D
|
|
216
296
|
regions: [], // optional: filter by specific regions
|
|
217
297
|
},
|
|
218
298
|
{ headers },
|
|
@@ -223,6 +303,8 @@ console.log(`Success: ${summary.totalSuccessful}`);
|
|
|
223
303
|
console.log(`Degraded: ${summary.totalDegraded}`);
|
|
224
304
|
console.log(`Failed: ${summary.totalFailed}`);
|
|
225
305
|
console.log(`P50 latency: ${summary.p50}ms`);
|
|
306
|
+
console.log(`P75 latency: ${summary.p75}ms`);
|
|
307
|
+
console.log(`P90 latency: ${summary.p90}ms`);
|
|
226
308
|
console.log(`P95 latency: ${summary.p95}ms`);
|
|
227
309
|
console.log(`P99 latency: ${summary.p99}ms`);
|
|
228
310
|
```
|
|
@@ -232,155 +314,383 @@ console.log(`P99 latency: ${summary.p99}ms`);
|
|
|
232
314
|
Check API health status (no authentication required).
|
|
233
315
|
|
|
234
316
|
```typescript
|
|
317
|
+
import { ServingStatus } from "@openstatus/sdk-node";
|
|
318
|
+
|
|
235
319
|
const { status } = await openstatus.health.v1.HealthService.check({});
|
|
236
|
-
console.log(status); // "SERVING"
|
|
320
|
+
console.log(ServingStatus[status]); // "SERVING"
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Status Report Service
|
|
324
|
+
|
|
325
|
+
Manage incident and maintenance reports with update timelines.
|
|
326
|
+
|
|
327
|
+
#### `createStatusReport(request, options)`
|
|
328
|
+
|
|
329
|
+
Create a new status report.
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
import { StatusReportStatus } from "@openstatus/sdk-node";
|
|
333
|
+
|
|
334
|
+
const { statusReport } = await openstatus.statusReport.v1.StatusReportService
|
|
335
|
+
.createStatusReport(
|
|
336
|
+
{
|
|
337
|
+
title: "API Degradation",
|
|
338
|
+
status: StatusReportStatus.INVESTIGATING,
|
|
339
|
+
message: "We are investigating reports of increased latency.",
|
|
340
|
+
date: "2024-01-15T10:30:00",
|
|
341
|
+
pageId: "page_123",
|
|
342
|
+
pageComponentIds: ["comp_456"],
|
|
343
|
+
notify: true,
|
|
344
|
+
},
|
|
345
|
+
{ headers },
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
console.log(`Status report created: ${statusReport?.id}`);
|
|
237
349
|
```
|
|
238
350
|
|
|
351
|
+
#### `getStatusReport(request, options)`
|
|
352
|
+
|
|
353
|
+
Get a status report by ID (includes full update timeline).
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
const { statusReport } = await openstatus.statusReport.v1.StatusReportService
|
|
357
|
+
.getStatusReport(
|
|
358
|
+
{ id: "sr_123" },
|
|
359
|
+
{ headers },
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
console.log(`Title: ${statusReport?.title}`);
|
|
363
|
+
console.log(`Status: ${StatusReportStatus[statusReport?.status ?? 0]}`);
|
|
364
|
+
|
|
365
|
+
// Access update timeline
|
|
366
|
+
for (const update of statusReport?.updates ?? []) {
|
|
367
|
+
console.log(`${update.date}: ${update.message}`);
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
#### `listStatusReports(request, options)`
|
|
372
|
+
|
|
373
|
+
List all status reports with pagination and optional filtering.
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
import { StatusReportStatus } from "@openstatus/sdk-node";
|
|
377
|
+
|
|
378
|
+
const { statusReports, totalSize } = await openstatus.statusReport.v1
|
|
379
|
+
.StatusReportService.listStatusReports(
|
|
380
|
+
{
|
|
381
|
+
limit: 10,
|
|
382
|
+
offset: 0,
|
|
383
|
+
statuses: [StatusReportStatus.INVESTIGATING, StatusReportStatus.IDENTIFIED],
|
|
384
|
+
},
|
|
385
|
+
{ headers },
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
console.log(`Found ${totalSize} status reports`);
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
#### `updateStatusReport(request, options)`
|
|
392
|
+
|
|
393
|
+
Update status report metadata (title, page components).
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
const { statusReport } = await openstatus.statusReport.v1.StatusReportService
|
|
397
|
+
.updateStatusReport(
|
|
398
|
+
{
|
|
399
|
+
id: "sr_123",
|
|
400
|
+
title: "Updated Title",
|
|
401
|
+
pageComponentIds: ["comp_456", "comp_789"],
|
|
402
|
+
},
|
|
403
|
+
{ headers },
|
|
404
|
+
);
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
#### `deleteStatusReport(request, options)`
|
|
408
|
+
|
|
409
|
+
Delete a status report and all its updates.
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
const { success } = await openstatus.statusReport.v1.StatusReportService
|
|
413
|
+
.deleteStatusReport(
|
|
414
|
+
{ id: "sr_123" },
|
|
415
|
+
{ headers },
|
|
416
|
+
);
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
#### `addStatusReportUpdate(request, options)`
|
|
420
|
+
|
|
421
|
+
Add a new update to an existing status report timeline.
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
import { StatusReportStatus } from "@openstatus/sdk-node";
|
|
425
|
+
|
|
426
|
+
const { statusReport } = await openstatus.statusReport.v1.StatusReportService
|
|
427
|
+
.addStatusReportUpdate(
|
|
428
|
+
{
|
|
429
|
+
statusReportId: "sr_123",
|
|
430
|
+
status: StatusReportStatus.IDENTIFIED,
|
|
431
|
+
message: "The issue has been identified as a database connection problem.",
|
|
432
|
+
date: "2024-01-15T11:00:00", // optional, defaults to current time
|
|
433
|
+
notify: true,
|
|
434
|
+
},
|
|
435
|
+
{ headers },
|
|
436
|
+
);
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Status Report Status
|
|
440
|
+
|
|
441
|
+
| Enum Value | Description |
|
|
442
|
+
| --------------- | ------------------------------- |
|
|
443
|
+
| `UNSPECIFIED` | Default/unspecified status |
|
|
444
|
+
| `INVESTIGATING` | Actively investigating the issue |
|
|
445
|
+
| `IDENTIFIED` | Root cause has been identified |
|
|
446
|
+
| `MONITORING` | Fix deployed, monitoring |
|
|
447
|
+
| `RESOLVED` | Issue fully resolved |
|
|
448
|
+
|
|
239
449
|
## Monitor Options
|
|
240
450
|
|
|
241
451
|
### HTTP Monitor
|
|
242
452
|
|
|
243
|
-
| Option | Type
|
|
244
|
-
| ---------------------- |
|
|
245
|
-
| `name` | string
|
|
246
|
-
| `url` | string
|
|
247
|
-
| `periodicity` |
|
|
248
|
-
| `method` |
|
|
249
|
-
| `body` | string
|
|
250
|
-
| `headers` |
|
|
251
|
-
| `timeout` |
|
|
252
|
-
| `retry` |
|
|
253
|
-
| `followRedirects` | boolean
|
|
254
|
-
| `regions` |
|
|
255
|
-
| `active` | boolean
|
|
256
|
-
| `public` | boolean
|
|
257
|
-
| `degradedAt` |
|
|
258
|
-
| `
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
453
|
+
| Option | Type | Required | Description |
|
|
454
|
+
| ---------------------- | ------------------- | -------- | --------------------------------------------------- |
|
|
455
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
456
|
+
| `url` | string | Yes | URL to monitor (max 2048 chars) |
|
|
457
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
458
|
+
| `method` | HTTPMethod | No | HTTP method (see [HTTP Methods](#http-methods)) |
|
|
459
|
+
| `body` | string | No | Request body |
|
|
460
|
+
| `headers` | Headers[] | No | Custom headers (`{ key: string, value: string }[]`) |
|
|
461
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
462
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
463
|
+
| `followRedirects` | boolean | No | Follow redirects (default: true) |
|
|
464
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
465
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
466
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
467
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
468
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
469
|
+
| `statusCodeAssertions` | array | No | [Status code assertions](#status-code-assertions) |
|
|
470
|
+
| `bodyAssertions` | array | No | [Body assertions](#body-assertions) |
|
|
471
|
+
| `headerAssertions` | array | No | [Header assertions](#header-assertions) |
|
|
472
|
+
| `openTelemetry` | OpenTelemetryConfig | No | OpenTelemetry export configuration |
|
|
261
473
|
|
|
262
474
|
### TCP Monitor
|
|
263
475
|
|
|
264
|
-
| Option
|
|
265
|
-
|
|
|
266
|
-
| `name`
|
|
267
|
-
| `uri`
|
|
268
|
-
| `periodicity`
|
|
269
|
-
| `timeout`
|
|
270
|
-
| `retry`
|
|
271
|
-
| `regions`
|
|
272
|
-
| `active`
|
|
476
|
+
| Option | Type | Required | Description |
|
|
477
|
+
| --------------- | ------------------- | -------- | ------------------------------------------------ |
|
|
478
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
479
|
+
| `uri` | string | Yes | `host:port` to monitor (max 2048 chars) |
|
|
480
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
481
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
482
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
483
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
484
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
485
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
486
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
487
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
488
|
+
| `openTelemetry` | OpenTelemetryConfig | No | OpenTelemetry export configuration |
|
|
273
489
|
|
|
274
490
|
### DNS Monitor
|
|
275
491
|
|
|
276
|
-
| Option | Type
|
|
277
|
-
| ------------------ |
|
|
278
|
-
| `name` | string
|
|
279
|
-
| `uri` | string
|
|
280
|
-
| `periodicity` |
|
|
281
|
-
| `timeout` |
|
|
282
|
-
| `retry` |
|
|
283
|
-
| `regions` |
|
|
284
|
-
| `
|
|
492
|
+
| Option | Type | Required | Description |
|
|
493
|
+
| ------------------ | ------------------- | -------- | ------------------------------------------------ |
|
|
494
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
495
|
+
| `uri` | string | Yes | Domain to resolve (max 2048 chars) |
|
|
496
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
497
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
498
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
499
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
500
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
501
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
502
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
503
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
504
|
+
| `recordAssertions` | array | No | [DNS record assertions](#dns-record-assertions) |
|
|
505
|
+
| `openTelemetry` | OpenTelemetryConfig | No | OpenTelemetry export configuration |
|
|
506
|
+
|
|
507
|
+
### Periodicity
|
|
508
|
+
|
|
509
|
+
| Enum Value | Description |
|
|
510
|
+
| ----------------- | ----------- |
|
|
511
|
+
| `PERIODICITY_30S` | Every 30s |
|
|
512
|
+
| `PERIODICITY_1M` | Every 1m |
|
|
513
|
+
| `PERIODICITY_5M` | Every 5m |
|
|
514
|
+
| `PERIODICITY_10M` | Every 10m |
|
|
515
|
+
| `PERIODICITY_30M` | Every 30m |
|
|
516
|
+
| `PERIODICITY_1H` | Every 1h |
|
|
517
|
+
|
|
518
|
+
### HTTP Methods
|
|
519
|
+
|
|
520
|
+
| Enum Value | Description |
|
|
521
|
+
| --------------------- | ----------- |
|
|
522
|
+
| `HTTP_METHOD_GET` | GET |
|
|
523
|
+
| `HTTP_METHOD_POST` | POST |
|
|
524
|
+
| `HTTP_METHOD_HEAD` | HEAD |
|
|
525
|
+
| `HTTP_METHOD_PUT` | PUT |
|
|
526
|
+
| `HTTP_METHOD_PATCH` | PATCH |
|
|
527
|
+
| `HTTP_METHOD_DELETE` | DELETE |
|
|
528
|
+
| `HTTP_METHOD_TRACE` | TRACE |
|
|
529
|
+
| `HTTP_METHOD_CONNECT` | CONNECT |
|
|
530
|
+
| `HTTP_METHOD_OPTIONS` | OPTIONS |
|
|
285
531
|
|
|
286
532
|
## Assertions
|
|
287
533
|
|
|
534
|
+
All assertion comparators are exported as enums from the SDK.
|
|
535
|
+
|
|
288
536
|
### Status Code Assertions
|
|
289
537
|
|
|
290
|
-
Validate HTTP response status codes
|
|
538
|
+
Validate HTTP response status codes using `NumberComparator`.
|
|
291
539
|
|
|
292
540
|
```typescript
|
|
541
|
+
import { NumberComparator } from "@openstatus/sdk-node";
|
|
542
|
+
|
|
293
543
|
{
|
|
294
544
|
statusCodeAssertions: [
|
|
295
|
-
{ comparator:
|
|
296
|
-
{ comparator:
|
|
545
|
+
{ comparator: NumberComparator.EQUAL, target: BigInt(200) },
|
|
546
|
+
{ comparator: NumberComparator.LESS_THAN, target: BigInt(400) },
|
|
297
547
|
];
|
|
298
548
|
}
|
|
299
549
|
```
|
|
300
550
|
|
|
301
|
-
**
|
|
302
|
-
|
|
551
|
+
**NumberComparator values:**
|
|
552
|
+
|
|
553
|
+
| Enum Value | Description |
|
|
554
|
+
| ----------------------- | --------------------- |
|
|
555
|
+
| `EQUAL` | Equal to target |
|
|
556
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
557
|
+
| `GREATER_THAN` | Greater than target |
|
|
558
|
+
| `GREATER_THAN_OR_EQUAL` | Greater than or equal |
|
|
559
|
+
| `LESS_THAN` | Less than target |
|
|
560
|
+
| `LESS_THAN_OR_EQUAL` | Less than or equal |
|
|
303
561
|
|
|
304
562
|
### Body Assertions
|
|
305
563
|
|
|
306
|
-
Validate response body content
|
|
564
|
+
Validate response body content using `StringComparator`.
|
|
307
565
|
|
|
308
566
|
```typescript
|
|
567
|
+
import { StringComparator } from "@openstatus/sdk-node";
|
|
568
|
+
|
|
309
569
|
{
|
|
310
570
|
bodyAssertions: [
|
|
311
|
-
{ comparator:
|
|
312
|
-
{ comparator:
|
|
571
|
+
{ comparator: StringComparator.CONTAINS, target: '"status":"ok"' },
|
|
572
|
+
{ comparator: StringComparator.NOT_EMPTY, target: "" },
|
|
313
573
|
];
|
|
314
574
|
}
|
|
315
575
|
```
|
|
316
576
|
|
|
317
|
-
**
|
|
318
|
-
|
|
577
|
+
**StringComparator values:**
|
|
578
|
+
|
|
579
|
+
| Enum Value | Description |
|
|
580
|
+
| ----------------------- | --------------------------- |
|
|
581
|
+
| `CONTAINS` | Contains target string |
|
|
582
|
+
| `NOT_CONTAINS` | Does not contain target |
|
|
583
|
+
| `EQUAL` | Equal to target |
|
|
584
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
585
|
+
| `EMPTY` | Body is empty |
|
|
586
|
+
| `NOT_EMPTY` | Body is not empty |
|
|
587
|
+
| `GREATER_THAN` | Lexicographically greater |
|
|
588
|
+
| `GREATER_THAN_OR_EQUAL` | Lexicographically >= target |
|
|
589
|
+
| `LESS_THAN` | Lexicographically less |
|
|
590
|
+
| `LESS_THAN_OR_EQUAL` | Lexicographically <= target |
|
|
319
591
|
|
|
320
592
|
### Header Assertions
|
|
321
593
|
|
|
322
|
-
Validate response headers
|
|
594
|
+
Validate response headers using `StringComparator`.
|
|
323
595
|
|
|
324
596
|
```typescript
|
|
597
|
+
import { StringComparator } from "@openstatus/sdk-node";
|
|
598
|
+
|
|
325
599
|
{
|
|
326
600
|
headerAssertions: [
|
|
327
|
-
{
|
|
601
|
+
{
|
|
602
|
+
key: "content-type",
|
|
603
|
+
comparator: StringComparator.CONTAINS,
|
|
604
|
+
target: "application/json",
|
|
605
|
+
},
|
|
328
606
|
];
|
|
329
607
|
}
|
|
330
608
|
```
|
|
331
609
|
|
|
332
610
|
### DNS Record Assertions
|
|
333
611
|
|
|
334
|
-
Validate DNS records
|
|
612
|
+
Validate DNS records using `RecordComparator`.
|
|
335
613
|
|
|
336
614
|
```typescript
|
|
615
|
+
import { RecordComparator } from "@openstatus/sdk-node";
|
|
616
|
+
|
|
337
617
|
{
|
|
338
618
|
recordAssertions: [
|
|
339
|
-
{
|
|
340
|
-
|
|
619
|
+
{
|
|
620
|
+
record: "A",
|
|
621
|
+
comparator: RecordComparator.EQUAL,
|
|
622
|
+
target: "93.184.216.34",
|
|
623
|
+
},
|
|
624
|
+
{ record: "CNAME", comparator: RecordComparator.CONTAINS, target: "cdn" },
|
|
341
625
|
];
|
|
342
626
|
}
|
|
343
627
|
```
|
|
344
628
|
|
|
345
|
-
**
|
|
629
|
+
**RecordComparator values:**
|
|
630
|
+
|
|
631
|
+
| Enum Value | Description |
|
|
632
|
+
| -------------- | ----------------------- |
|
|
633
|
+
| `EQUAL` | Equal to target |
|
|
634
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
635
|
+
| `CONTAINS` | Contains target string |
|
|
636
|
+
| `NOT_CONTAINS` | Does not contain target |
|
|
637
|
+
|
|
638
|
+
**Supported record types:** `A`, `AAAA`, `CNAME`, `MX`, `TXT`
|
|
346
639
|
|
|
347
640
|
## Regions
|
|
348
641
|
|
|
349
|
-
Monitor from 28 global locations across multiple providers
|
|
642
|
+
Monitor from 28 global locations across multiple providers. Use the `Region`
|
|
643
|
+
enum:
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
import { Region } from "@openstatus/sdk-node";
|
|
647
|
+
|
|
648
|
+
// Example: Use specific regions
|
|
649
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.KOYEB_FRA];
|
|
650
|
+
```
|
|
350
651
|
|
|
351
652
|
### Fly.io Regions
|
|
352
653
|
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
| `
|
|
654
|
+
| Enum Value | Location |
|
|
655
|
+
| ---------- | --------------- |
|
|
656
|
+
| `FLY_AMS` | Amsterdam |
|
|
657
|
+
| `FLY_ARN` | Stockholm |
|
|
658
|
+
| `FLY_BOM` | Mumbai |
|
|
659
|
+
| `FLY_CDG` | Paris |
|
|
660
|
+
| `FLY_DFW` | Dallas |
|
|
661
|
+
| `FLY_EWR` | Newark |
|
|
662
|
+
| `FLY_FRA` | Frankfurt |
|
|
663
|
+
| `FLY_GRU` | São Paulo |
|
|
664
|
+
| `FLY_IAD` | Washington D.C. |
|
|
665
|
+
| `FLY_JNB` | Johannesburg |
|
|
666
|
+
| `FLY_LAX` | Los Angeles |
|
|
667
|
+
| `FLY_LHR` | London |
|
|
668
|
+
| `FLY_NRT` | Tokyo |
|
|
669
|
+
| `FLY_ORD` | Chicago |
|
|
670
|
+
| `FLY_SJC` | San Jose |
|
|
671
|
+
| `FLY_SIN` | Singapore |
|
|
672
|
+
| `FLY_SYD` | Sydney |
|
|
673
|
+
| `FLY_YYZ` | Toronto |
|
|
364
674
|
|
|
365
675
|
### Koyeb Regions
|
|
366
676
|
|
|
367
|
-
|
|
|
677
|
+
| Enum Value | Location |
|
|
368
678
|
| ----------- | ------------- |
|
|
369
|
-
| `
|
|
370
|
-
| `
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
| `
|
|
679
|
+
| `KOYEB_FRA` | Frankfurt |
|
|
680
|
+
| `KOYEB_PAR` | Paris |
|
|
681
|
+
| `KOYEB_SFO` | San Francisco |
|
|
682
|
+
| `KOYEB_SIN` | Singapore |
|
|
683
|
+
| `KOYEB_TYO` | Tokyo |
|
|
684
|
+
| `KOYEB_WAS` | Washington |
|
|
375
685
|
|
|
376
686
|
### Railway Regions
|
|
377
687
|
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
| `
|
|
381
|
-
| `
|
|
382
|
-
| `
|
|
383
|
-
| `
|
|
688
|
+
| Enum Value | Location |
|
|
689
|
+
| ------------------------- | -------------- |
|
|
690
|
+
| `RAILWAY_US_WEST2` | US West |
|
|
691
|
+
| `RAILWAY_US_EAST4` | US East |
|
|
692
|
+
| `RAILWAY_EUROPE_WEST4` | Europe West |
|
|
693
|
+
| `RAILWAY_ASIA_SOUTHEAST1` | Asia Southeast |
|
|
384
694
|
|
|
385
695
|
## Error Handling
|
|
386
696
|
|