watchfor 0.11.0 → 0.12.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 +8 -0
- package/dist/cli.js +11 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.js +12 -1
- package/dist/schema.d.ts +67 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,14 @@ Toolbox. Details: https://watchfor.io/docs/api/diagnostics
|
|
|
91
91
|
- `WatchForError` carries `status`, `code` and `retryAfterSeconds`
|
|
92
92
|
- Pass an idempotency key as the second argument of any `create` call for safe retries
|
|
93
93
|
|
|
94
|
+
## Prometheus metrics (Pro plan and above)
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const text = await wf.metrics({ tag: "production" }); // Prometheus text format
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Usually you point Prometheus at `https://watchfor.io/api/v1/metrics` directly; this is for scripts and one-off checks. See https://watchfor.io/docs/api/prometheus.
|
|
101
|
+
|
|
94
102
|
## CLI
|
|
95
103
|
|
|
96
104
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,8 @@ Usage:
|
|
|
19
19
|
Recent probe results for one monitor
|
|
20
20
|
(prints the next_cursor for older pages)
|
|
21
21
|
watchfor report [--period 7d|30d] Org report vs the previous period
|
|
22
|
+
watchfor metrics [--tag t] [--type t]
|
|
23
|
+
Prometheus text format (Pro plan and above)
|
|
22
24
|
watchfor help
|
|
23
25
|
|
|
24
26
|
Environment:
|
|
@@ -55,6 +57,15 @@ async function main() {
|
|
|
55
57
|
console.log(`incidents: ${i.firing} firing (${i.firing_critical} critical) · ${i.acknowledged} acknowledged · ${i.started_24h} started in 24h`);
|
|
56
58
|
return 0;
|
|
57
59
|
}
|
|
60
|
+
case "metrics": {
|
|
61
|
+
const tag = flag(args, "tag");
|
|
62
|
+
const type = flag(args, "type");
|
|
63
|
+
process.stdout.write(await wf.metrics({
|
|
64
|
+
...(tag && tag !== "true" ? { tag } : {}),
|
|
65
|
+
...(type && type !== "true" ? { type } : {}),
|
|
66
|
+
}));
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
58
69
|
case "report": {
|
|
59
70
|
const idx = args.indexOf("--period");
|
|
60
71
|
const period = idx !== -1 && (args[idx + 1] === "30d" || args[idx + 1] === "7d")
|
package/dist/client.d.ts
CHANGED
|
@@ -80,6 +80,18 @@ export declare class WatchFor {
|
|
|
80
80
|
me(): Promise<unknown>;
|
|
81
81
|
/** One-call org snapshot: monitor status counts + active incidents. */
|
|
82
82
|
summary(): Promise<Summary>;
|
|
83
|
+
/**
|
|
84
|
+
* The organization in Prometheus text format (Pro plan and above):
|
|
85
|
+
* status, uptime, response times, expiry, heartbeats, hosts. Cached for
|
|
86
|
+
* 60 s server-side. Filters: tag, type, monitor_id (comma-separated),
|
|
87
|
+
* include_hosts.
|
|
88
|
+
*/
|
|
89
|
+
metrics(query?: {
|
|
90
|
+
tag?: string;
|
|
91
|
+
type?: string;
|
|
92
|
+
monitor_id?: string;
|
|
93
|
+
include_hosts?: boolean;
|
|
94
|
+
}): Promise<string>;
|
|
83
95
|
/** Plan limits and live usage. */
|
|
84
96
|
plan(): Promise<Plan>;
|
|
85
97
|
/** Aggregate incident stats: MTTR, MTBF, most unstable monitors. */
|
package/dist/client.js
CHANGED
|
@@ -29,7 +29,7 @@ export class WatchFor {
|
|
|
29
29
|
}
|
|
30
30
|
const headers = {
|
|
31
31
|
Authorization: `Bearer ${this.apiKey}`,
|
|
32
|
-
Accept: "application/json",
|
|
32
|
+
Accept: opts.text ? "text/plain, application/json" : "application/json",
|
|
33
33
|
};
|
|
34
34
|
if (opts.body !== undefined)
|
|
35
35
|
headers["Content-Type"] = "application/json";
|
|
@@ -42,6 +42,8 @@ export class WatchFor {
|
|
|
42
42
|
});
|
|
43
43
|
if (res.status === 204)
|
|
44
44
|
return undefined;
|
|
45
|
+
if (opts.text && res.ok)
|
|
46
|
+
return (await res.text());
|
|
45
47
|
let json = null;
|
|
46
48
|
try {
|
|
47
49
|
json = await res.json();
|
|
@@ -66,6 +68,15 @@ export class WatchFor {
|
|
|
66
68
|
summary() {
|
|
67
69
|
return this.request("GET", "/summary");
|
|
68
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The organization in Prometheus text format (Pro plan and above):
|
|
73
|
+
* status, uptime, response times, expiry, heartbeats, hosts. Cached for
|
|
74
|
+
* 60 s server-side. Filters: tag, type, monitor_id (comma-separated),
|
|
75
|
+
* include_hosts.
|
|
76
|
+
*/
|
|
77
|
+
metrics(query = {}) {
|
|
78
|
+
return this.request("GET", "/metrics", { query, text: true });
|
|
79
|
+
}
|
|
69
80
|
/** Plan limits and live usage. */
|
|
70
81
|
plan() {
|
|
71
82
|
return this.request("GET", "/plan");
|
package/dist/schema.d.ts
CHANGED
|
@@ -1009,6 +1009,26 @@ export interface paths {
|
|
|
1009
1009
|
patch?: never;
|
|
1010
1010
|
trace?: never;
|
|
1011
1011
|
};
|
|
1012
|
+
"/metrics": {
|
|
1013
|
+
parameters: {
|
|
1014
|
+
query?: never;
|
|
1015
|
+
header?: never;
|
|
1016
|
+
path?: never;
|
|
1017
|
+
cookie?: never;
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* Prometheus metrics: monitor status, uptime 24h/7d/30d, last check and 24h response times, certificate and domain expiry, heartbeat last ping, hosts, fleet health and open incidents (Pro plan and above)
|
|
1021
|
+
* @description Prometheus text exposition 0.0.4 for `scrape_configs` (`authorization: { credentials: wf_live_… }`). The body is computed at most once a minute per organization and filter and cached for 60 s — scrape every 60s; `watchfor_scrape_generated_timestamp_seconds` shows its age. Own limit: 30 requests a minute per organization, on top of the per-key API limit. Per-object series carry only `monitor_id` / `host_id`; join names with `* on(monitor_id) group_left(name, type) watchfor_monitor_info`. Uptime is incident-based (confirmed critical downtime, maintenance excluded), identical to the dashboard. 403 when the plan does not include it.
|
|
1022
|
+
*/
|
|
1023
|
+
get: operations["getPrometheusMetrics"];
|
|
1024
|
+
put?: never;
|
|
1025
|
+
post?: never;
|
|
1026
|
+
delete?: never;
|
|
1027
|
+
options?: never;
|
|
1028
|
+
head?: never;
|
|
1029
|
+
patch?: never;
|
|
1030
|
+
trace?: never;
|
|
1031
|
+
};
|
|
1012
1032
|
"/incidents/stats": {
|
|
1013
1033
|
parameters: {
|
|
1014
1034
|
query?: never;
|
|
@@ -2702,6 +2722,8 @@ export interface components {
|
|
|
2702
2722
|
severity?: "critical" | "warning";
|
|
2703
2723
|
}[];
|
|
2704
2724
|
};
|
|
2725
|
+
/** @description Prometheus text exposition format 0.0.4: `# HELP` / `# TYPE` lines and one sample per line. Families: watchfor_organization_info, watchfor_monitors, watchfor_health_score, watchfor_incidents_firing, watchfor_incidents_acknowledged, watchfor_maintenance_windows_active, watchfor_hosts, watchfor_monitor_info, watchfor_monitor_up, watchfor_monitor_state, watchfor_monitor_paused, watchfor_monitor_open_incident_severity, watchfor_monitor_check_interval_seconds, watchfor_monitor_last_check_timestamp_seconds, watchfor_monitor_last_check_success, watchfor_monitor_last_check_duration_seconds, watchfor_monitor_checks_24h, watchfor_monitor_avg_duration_24h_seconds, watchfor_monitor_uptime_ratio, watchfor_ssl_certificate_expiry_timestamp_seconds, watchfor_domain_expiry_timestamp_seconds, watchfor_heartbeat_last_ping_timestamp_seconds, watchfor_host_info, watchfor_host_up, watchfor_host_last_seen_timestamp_seconds, watchfor_scrape_generated_timestamp_seconds, watchfor_scrape_duration_seconds. */
|
|
2726
|
+
PrometheusExposition: string;
|
|
2705
2727
|
Summary: {
|
|
2706
2728
|
/** @constant */
|
|
2707
2729
|
object?: "summary";
|
|
@@ -5983,6 +6005,51 @@ export interface operations {
|
|
|
5983
6005
|
};
|
|
5984
6006
|
};
|
|
5985
6007
|
};
|
|
6008
|
+
getPrometheusMetrics: {
|
|
6009
|
+
parameters: {
|
|
6010
|
+
query?: {
|
|
6011
|
+
/** @description Only monitors carrying one of these tags (repeat or comma-separate). Organization totals always cover the whole organization. */
|
|
6012
|
+
tag?: string;
|
|
6013
|
+
/** @description Only monitors of these types (repeat or comma-separate) */
|
|
6014
|
+
type?: string;
|
|
6015
|
+
/** @description Only these monitors (repeat or comma-separate) */
|
|
6016
|
+
monitor_id?: string;
|
|
6017
|
+
/** @description false drops the host families */
|
|
6018
|
+
include_hosts?: boolean;
|
|
6019
|
+
};
|
|
6020
|
+
header?: never;
|
|
6021
|
+
path?: never;
|
|
6022
|
+
cookie?: never;
|
|
6023
|
+
};
|
|
6024
|
+
requestBody?: never;
|
|
6025
|
+
responses: {
|
|
6026
|
+
/** @description Prometheus text exposition (format 0.0.4) */
|
|
6027
|
+
200: {
|
|
6028
|
+
headers: {
|
|
6029
|
+
/** @description Unix seconds when this (possibly cached) body was computed */
|
|
6030
|
+
"X-WatchFor-Metrics-Generated"?: number;
|
|
6031
|
+
[name: string]: unknown;
|
|
6032
|
+
};
|
|
6033
|
+
content: {
|
|
6034
|
+
/**
|
|
6035
|
+
* @example # HELP watchfor_monitor_up 1 unless a confirmed critical incident is open on the monitor.
|
|
6036
|
+
* # TYPE watchfor_monitor_up gauge
|
|
6037
|
+
* watchfor_monitor_up{monitor_id="0fe0d9ba-c062-48f5-a9ec-ead9a4076ebd"} 1
|
|
6038
|
+
*/
|
|
6039
|
+
"text/plain": components["schemas"]["PrometheusExposition"];
|
|
6040
|
+
};
|
|
6041
|
+
};
|
|
6042
|
+
/** @description Error */
|
|
6043
|
+
default: {
|
|
6044
|
+
headers: {
|
|
6045
|
+
[name: string]: unknown;
|
|
6046
|
+
};
|
|
6047
|
+
content: {
|
|
6048
|
+
"application/json": components["schemas"]["Error"];
|
|
6049
|
+
};
|
|
6050
|
+
};
|
|
6051
|
+
};
|
|
6052
|
+
};
|
|
5986
6053
|
getIncidentStats: {
|
|
5987
6054
|
parameters: {
|
|
5988
6055
|
query?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "watchfor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Official TypeScript SDK + CLI for WatchFor — uptime & infrastructure monitoring (monitors, alert rules, incidents, maintenance windows) over the REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"watchfor",
|