@glydeunity/unity-healthcheck-mesh 0.0.0-stage → 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/CHANGELOG.md +26 -0
- package/LICENSE +21 -0
- package/README.md +343 -2
- package/dist/cjs/config.js +408 -0
- package/dist/cjs/ids.js +53 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/probe.js +81 -0
- package/dist/cjs/reporters.js +334 -0
- package/dist/cjs/runner.js +234 -0
- package/dist/cjs/schedule.js +23 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/uuid5.js +45 -0
- package/dist/cjs/version.js +10 -0
- package/dist/esm/config.d.ts +85 -0
- package/dist/esm/config.js +402 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/ids.d.ts +47 -0
- package/dist/esm/ids.js +47 -0
- package/dist/esm/ids.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/probe.d.ts +45 -0
- package/dist/esm/probe.js +77 -0
- package/dist/esm/probe.js.map +1 -0
- package/dist/esm/reporters.d.ts +75 -0
- package/dist/esm/reporters.js +330 -0
- package/dist/esm/reporters.js.map +1 -0
- package/dist/esm/runner.d.ts +25 -0
- package/dist/esm/runner.js +230 -0
- package/dist/esm/runner.js.map +1 -0
- package/dist/esm/schedule.d.ts +15 -0
- package/dist/esm/schedule.js +20 -0
- package/dist/esm/schedule.js.map +1 -0
- package/dist/esm/types.d.ts +101 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/uuid5.d.ts +12 -0
- package/dist/esm/uuid5.js +42 -0
- package/dist/esm/uuid5.js.map +1 -0
- package/dist/esm/version.d.ts +7 -0
- package/dist/esm/version.js +8 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +53 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to @glydeunity/unity-healthcheck-mesh will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-11-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Mesh probes**: `startMeshProbes` probes each mesh's hosts on a minute-aligned interval and reports every observation; `runProbeRound` runs one round with no timers.
|
|
15
|
+
- **Deterministic dedup id**: every report carries `check_id = uuid5(namespace, "<minute>|<server>|<path>|<result>")`, so servers that saw the same result derive the same id without coordinating. A mesh's default namespace follows its `mesh-id`; an explicit `namespace` is shared across servers.
|
|
16
|
+
- **Four report formats**: `victorialogs/stdout` (one JSON line per report), `victorialogs` (JSON-line batch to `/insert/jsonline` with basic auth), `opentelemetry` (a log record per report and a `mesh_probe_up` gauge, through the host's own OpenTelemetry providers) and `bugsnag` (healthy/unhealthy transitions under a grouping hash that is stable per target).
|
|
17
|
+
- **Fail-closed config validation**: `MeshConfigError` names every offending path, including unknown keys, duplicate mesh ids or targets, embedded credentials, non-https destinations and ports fetch refuses.
|
|
18
|
+
- **Validate up front**: `parseMeshConfig` returns the validated config with defaults filled, in its own keys, and that output is accepted by `startMeshProbes` and `runProbeRound`.
|
|
19
|
+
- **Dual builds**: ESM with type declarations and CommonJS, with no runtime dependencies. `@opentelemetry/api` is an optional peer dependency.
|
|
20
|
+
|
|
21
|
+
### Known limitations
|
|
22
|
+
|
|
23
|
+
- Reports are deduplicated at query time in VictoriaLogs; VictoriaLogs itself stores every report.
|
|
24
|
+
- A target that stops being reported on is not detected. The package probes and reports; it does not alert.
|
|
25
|
+
- Bugsnag transition memory lives in the process, so a restart or a one-shot round reports the next failure it sees as new.
|
|
26
|
+
- The `opentelemetry` reporter sends nothing until the host has registered a provider; it then sends both signals.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GLYDE Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,344 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @glydeunity/unity-healthcheck-mesh
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
External health probes for a fleet of servers. Each server probes a list of
|
|
4
|
+
targets and reports what it saw, stamped with a deterministic dedup id. No server
|
|
5
|
+
knows about the others, nothing coordinates them, and every server can belong to
|
|
6
|
+
as many meshes as it can reach.
|
|
7
|
+
|
|
8
|
+
- **No runtime dependencies.** Node 20 or later; CommonJS and ESM builds.
|
|
9
|
+
- **One line to start.** `startMeshProbes({ meshes })`.
|
|
10
|
+
- **Four report formats.** `victorialogs/stdout`, `victorialogs` (HTTP ingest),
|
|
11
|
+
`opentelemetry` and `bugsnag`.
|
|
12
|
+
|
|
13
|
+
## How the dedup id works
|
|
14
|
+
|
|
15
|
+
Every observation gets
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
check_id = uuid5(namespace, "<minute>|<server>|<path>|<result>")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Part | Value |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `minute` | Start of the minute the round was scheduled in, as ISO 8601 UTC: `2026-11-27T03:10:00.000Z` |
|
|
24
|
+
| `server` | Target hostname, lowercased |
|
|
25
|
+
| `path` | Request path |
|
|
26
|
+
| `result` | HTTP status as text (`200`) or a failure class: `TIMEOUT`, `DNS`, `REFUSED`, `TLS`, `RESET`, `NETWORK` |
|
|
27
|
+
| `namespace` | The mesh's `namespace`. Default: `uuid5(ROOT, "<mesh-id>")` — see below |
|
|
28
|
+
|
|
29
|
+
The default namespace is `uuid5(ROOT, "<mesh-id>")` with
|
|
30
|
+
`ROOT = b024abd5-11e8-56a6-87c3-4009cb18a821`, which is
|
|
31
|
+
`uuid5(DNS namespace, "unity-mesh.glydeunity.com")`. Servers therefore agree on
|
|
32
|
+
ids from a `mesh-id` alone. An explicit `namespace` must be identical in every
|
|
33
|
+
server's config.
|
|
34
|
+
|
|
35
|
+
To derive the same id in another language, follow RFC 4122 section 4.3: SHA-1
|
|
36
|
+
over the 16 namespace bytes followed by the UTF-8 name, keep the first 16 bytes,
|
|
37
|
+
set the version to 5 and the two variant bits to `10`.
|
|
38
|
+
|
|
39
|
+
What follows from the recipe:
|
|
40
|
+
|
|
41
|
+
- **Agreement collapses.** Every server and every instance that saw the same
|
|
42
|
+
result for the same target in the same minute derives the same id.
|
|
43
|
+
- **Disagreement survives.** A `200` from one server and a `TIMEOUT` from
|
|
44
|
+
another are two ids, and each report names the server that saw it.
|
|
45
|
+
- **Rounds are aligned.** Every mesh fires five seconds past each interval
|
|
46
|
+
boundary, so servers on synced clocks observe within one dedup minute.
|
|
47
|
+
- **The count is recoverable.** The observing server is not part of the id, so
|
|
48
|
+
collapsed reports do not say how many agreed. `uniq by … with hits` does; see
|
|
49
|
+
[Reading the mesh in VictoriaLogs](#reading-the-mesh-in-victorialogs).
|
|
50
|
+
|
|
51
|
+
## Install and start
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @glydeunity/unity-healthcheck-mesh
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { startMeshProbes } from '@glydeunity/unity-healthcheck-mesh';
|
|
59
|
+
import pkg from './package.json';
|
|
60
|
+
|
|
61
|
+
const probes = startMeshProbes({ meshes: pkg['unity-mesh'] });
|
|
62
|
+
// At shutdown:
|
|
63
|
+
await probes.stop();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`startMeshProbes` validates the whole mesh list first and throws
|
|
67
|
+
`MeshConfigError`, naming every offending path, before it schedules anything.
|
|
68
|
+
In a server, start it once the process is ready, after its telemetry, and stop
|
|
69
|
+
it on shutdown; for a Fastify app that is `app.addHook('onReady', …)` and
|
|
70
|
+
`app.addHook('onClose', …)`.
|
|
71
|
+
|
|
72
|
+
To validate at a different moment, `parseMeshConfig(meshes)` does the check on
|
|
73
|
+
its own. It returns the config with defaults filled, in the config's own keys,
|
|
74
|
+
and that output is accepted as `meshes`:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { parseMeshConfig, startMeshProbes } from '@glydeunity/unity-healthcheck-mesh';
|
|
78
|
+
|
|
79
|
+
const meshes = parseMeshConfig(pkg['unity-mesh']);
|
|
80
|
+
const probes = startMeshProbes({ meshes });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The handle:
|
|
84
|
+
|
|
85
|
+
| Member | Does |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `meshes` | Ids of the meshes this server runs, after the `environments` gate |
|
|
88
|
+
| `run()` | Runs one round now on every mesh and returns its reports |
|
|
89
|
+
| `stop()` | Cancels future rounds and waits for a round in flight to finish reporting |
|
|
90
|
+
|
|
91
|
+
`runProbeRound(options)` runs a single round with no timers.
|
|
92
|
+
|
|
93
|
+
Timers are ordinary ones, so `startMeshProbes` keeps a bare script alive until
|
|
94
|
+
`stop()` is called.
|
|
95
|
+
|
|
96
|
+
## Config
|
|
97
|
+
|
|
98
|
+
The `unity-mesh` key holds an array of meshes. Each server carries only the
|
|
99
|
+
meshes it takes part in.
|
|
100
|
+
|
|
101
|
+
```jsonc
|
|
102
|
+
{
|
|
103
|
+
"unity-mesh": [
|
|
104
|
+
{
|
|
105
|
+
"mesh-id": "production",
|
|
106
|
+
"environments": ["production"],
|
|
107
|
+
"interval-seconds": 60,
|
|
108
|
+
"hosts": [
|
|
109
|
+
{ "server": "api.example.com", "path": "/health" },
|
|
110
|
+
{ "server": "sessions.example.com", "path": "/health/redis", "expect": [200, 204], "timeout-ms": 3000 }
|
|
111
|
+
],
|
|
112
|
+
"report": [
|
|
113
|
+
{ "payload-format": "opentelemetry" },
|
|
114
|
+
{ "payload-format": "victorialogs/stdout" },
|
|
115
|
+
{ "payload-format": "bugsnag" }
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"mesh-id": "shared",
|
|
120
|
+
"namespace": "11111111-2222-4333-8444-555555555555",
|
|
121
|
+
"hosts": [{ "server": "api.example.com", "path": "/version" }],
|
|
122
|
+
"report": { "target-url": "https://logs.example.com", "payload-format": "victorialogs" }
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
A full example is in [`examples/package-json-snippet.json`](./examples/package-json-snippet.json).
|
|
129
|
+
|
|
130
|
+
Validation fails closed. Unknown keys, duplicate mesh ids or targets,
|
|
131
|
+
credentials embedded in a URL, non-https destinations, a `payload-format`
|
|
132
|
+
with a typo, and ports fetch refuses are all rejected, each with the path it
|
|
133
|
+
concerns.
|
|
134
|
+
|
|
135
|
+
### Mesh
|
|
136
|
+
|
|
137
|
+
| Key | Required | Default | Notes |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| `mesh-id` | yes | | `[a-z0-9][a-z0-9._-]{0,63}` |
|
|
140
|
+
| `namespace` | no | `uuid5(ROOT, mesh-id)` | A UUID. Must match on every server of the mesh |
|
|
141
|
+
| `environments` | no | every environment | `NODE_ENV` values this mesh runs in |
|
|
142
|
+
| `interval-seconds` | no | `60` | A multiple of 60, from 60 to 86400 |
|
|
143
|
+
| `hosts` | yes | | At least one |
|
|
144
|
+
| `report` | yes | | One target or an array |
|
|
145
|
+
|
|
146
|
+
### Host
|
|
147
|
+
|
|
148
|
+
| Key | Default | Notes |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| `server` | | Required. Bare hostname; no scheme, port or path |
|
|
151
|
+
| `path` | `/` | Must start with `/` |
|
|
152
|
+
| `scheme` | `https` | `http` is allowed, for targets that do not offer https |
|
|
153
|
+
| `port` | the scheme's port | A port fetch refuses outright (`9`, `22`, `25`, `465`, `587`, …) is rejected, because a probe could never reach it |
|
|
154
|
+
| `expect` | `200` | A status code or an array of them that count as healthy |
|
|
155
|
+
| `timeout-ms` | `5000` | Give-up time for one probe |
|
|
156
|
+
|
|
157
|
+
Each probe is a `GET` with a `@glydeunity/unity-healthcheck-mesh/<version>
|
|
158
|
+
(<observer>)` user agent. Redirects are reported, not followed. The response
|
|
159
|
+
body is never read. One target may be listed once per mesh: `server` and `path`
|
|
160
|
+
are what the id is made of.
|
|
161
|
+
|
|
162
|
+
### Report target
|
|
163
|
+
|
|
164
|
+
| Key | Default | Notes |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `payload-format` | | `victorialogs/stdout`, `victorialogs`, `opentelemetry` or `bugsnag` |
|
|
167
|
+
| `target-url` | | See the table below |
|
|
168
|
+
| `timeout-ms` | `10000` | Give-up time for one report request |
|
|
169
|
+
| `api-key-env` | `BUGSNAG_API_KEY` | `bugsnag`: variable holding the notifier API key |
|
|
170
|
+
| `username-env` | `VICTORIA_LOGS_USERNAME` | `victorialogs`: variable holding the basic-auth username |
|
|
171
|
+
| `password-env` | `VICTORIA_LOGS_PASSWORD` | `victorialogs`: variable holding the basic-auth password |
|
|
172
|
+
|
|
173
|
+
| `payload-format` | `target-url` |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `victorialogs/stdout` | Omit, or `stdout` |
|
|
176
|
+
| `opentelemetry` | Omit. Reports go through this process's own OpenTelemetry providers |
|
|
177
|
+
| `victorialogs` | Required. Ingest base URL; the reporter posts to its `/insert/jsonline` |
|
|
178
|
+
| `bugsnag` | Optional, `https://notify.bugsnag.com`. For dashboards on `app.bugsnag.smartbear.com` use `https://notify.bugsnag.smartbear.com` |
|
|
179
|
+
|
|
180
|
+
Credentials are read from environment variables and never from the config.
|
|
181
|
+
Destinations must use https; `http` is accepted only on loopback, for tests.
|
|
182
|
+
|
|
183
|
+
### Runtime options
|
|
184
|
+
|
|
185
|
+
`startMeshProbes` and `runProbeRound` take the mesh list plus overrides, all
|
|
186
|
+
optional except `meshes`: `observer`, `environment`, `now`, `fetch`, `env`,
|
|
187
|
+
`writeLine` and `log`.
|
|
188
|
+
|
|
189
|
+
| Option | Default |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `observer` | `WEBSITE_HOSTNAME`, then `HOSTNAME`, then `unknown` |
|
|
192
|
+
| `environment` | `NODE_ENV`, then `unknown` |
|
|
193
|
+
|
|
194
|
+
## Where reports go
|
|
195
|
+
|
|
196
|
+
Every round produces one report per host. A report is:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{"v":1,"check_id":"83e53293-796a-52b5-8516-ccdfc54c67b4","mesh":"production","observer":"unity-prod","server":"api.example.com","scheme":"https","port":443,"path":"/health","result":"200","healthy":true,"status":200,"latency_ms":123,"at":"2026-11-27T03:10:05.123Z","minute":"2026-11-27T03:10:00.000Z"}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### `victorialogs/stdout`
|
|
203
|
+
|
|
204
|
+
Prints one JSON line per report. Healthy reports go to `console.info`, unhealthy
|
|
205
|
+
ones to `console.warn`, so a stdout shipper can file failures under a level of
|
|
206
|
+
their own. This is the format to use where a console shipper already forwards
|
|
207
|
+
stdout to VictoriaLogs: the line becomes the log entry's message.
|
|
208
|
+
|
|
209
|
+
### `victorialogs`
|
|
210
|
+
|
|
211
|
+
Posts the round's reports as one JSON-line batch to
|
|
212
|
+
`<target-url>/insert/jsonline`, with basic auth from the two env variables. Each
|
|
213
|
+
line is a VictoriaLogs log entry: `mesh` and `observer` are stream labels and
|
|
214
|
+
every other field stays a plain field.
|
|
215
|
+
|
|
216
|
+
### `opentelemetry`
|
|
217
|
+
|
|
218
|
+
Emits through the OpenTelemetry providers the host process has already
|
|
219
|
+
registered. See [OpenTelemetry](#opentelemetry).
|
|
220
|
+
|
|
221
|
+
### `bugsnag`
|
|
222
|
+
|
|
223
|
+
Reports transitions, not observations: one event when a target starts failing
|
|
224
|
+
and one when it recovers. See [Bugsnag](#bugsnag).
|
|
225
|
+
|
|
226
|
+
A reporter that fails does not affect the round. The problem is logged once,
|
|
227
|
+
then stays quiet for ten minutes per reporter.
|
|
228
|
+
|
|
229
|
+
## Reading the mesh in VictoriaLogs
|
|
230
|
+
|
|
231
|
+
VictoriaLogs is append-only; it keeps every report. The dedup happens in the
|
|
232
|
+
query, on `check_id`.
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
# One row per minute, target and result, with the number of reports that agreed
|
|
236
|
+
mesh:production | uniq by (check_id, server, path, result, healthy) with hits
|
|
237
|
+
|
|
238
|
+
# The same, split by the server that observed it
|
|
239
|
+
mesh:production | uniq by (check_id, observer, result) with hits
|
|
240
|
+
|
|
241
|
+
# Every distinct unhealthy result seen today
|
|
242
|
+
mesh:production AND healthy:false | uniq by (server, path, result) with hits
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Reports that arrived through `victorialogs/stdout` are JSON inside the message
|
|
246
|
+
and need unpacking first:
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
service:unity AND _msg:"mesh_probe" | unpack_json from _msg
|
|
250
|
+
| uniq by (check_id, server, path, result, healthy) with hits
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## OpenTelemetry
|
|
254
|
+
|
|
255
|
+
`opentelemetry` has no destination of its own. It uses `@opentelemetry/api`,
|
|
256
|
+
which the host process provides:
|
|
257
|
+
|
|
258
|
+
- `@opentelemetry/api` is an **optional peer dependency**. Where it is not
|
|
259
|
+
installed the reporter is off, and says so once.
|
|
260
|
+
- It sends only where a provider is **registered**. A process that has the API
|
|
261
|
+
but no telemetry started is off too, and says so once. Start telemetry before
|
|
262
|
+
the probes.
|
|
263
|
+
|
|
264
|
+
Each round emits:
|
|
265
|
+
|
|
266
|
+
| Signal | What |
|
|
267
|
+
|---|---|
|
|
268
|
+
| Log record | One per report: `INFO` when healthy, `ERROR` otherwise. The body is the same summary the VictoriaLogs formats use; the report's fields are attributes |
|
|
269
|
+
| Gauge | `mesh_probe_up`: 1 when this observer's last probe of the target was healthy, 0 otherwise. Attributes: `mesh`, `observer`, `server`, `path` |
|
|
270
|
+
|
|
271
|
+
A host that runs Azure Monitor's OpenTelemetry distro needs nothing else:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
import { useAzureMonitor } from '@azure/monitor-opentelemetry';
|
|
275
|
+
|
|
276
|
+
useAzureMonitor({ azureMonitorExporterOptions: { connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING } });
|
|
277
|
+
// then startMeshProbes(...)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Both signals then reach Application Insights, and through it its Log Analytics
|
|
281
|
+
workspace. Queries to start from, in the Application Insights Logs view:
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
// Unhealthy observations, newest first
|
|
285
|
+
traces
|
|
286
|
+
| where message startswith "mesh_probe"
|
|
287
|
+
| where severityLevel >= 3
|
|
288
|
+
| project timestamp, message, properties_check_id
|
|
289
|
+
| order by timestamp desc
|
|
290
|
+
|
|
291
|
+
// Probe health per target over the last hour
|
|
292
|
+
customMetrics
|
|
293
|
+
| where name == "mesh_probe_up"
|
|
294
|
+
| summarize avg(value) by bin(timestamp, 5m), tostring(customDimensions.server), tostring(customDimensions.observer)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Bugsnag
|
|
298
|
+
|
|
299
|
+
Bugsnag groups events under a `groupingHash`; it does not reject repeats. A
|
|
300
|
+
per-minute hash would open a new error every minute a target stayed down. So
|
|
301
|
+
the hash is stable per mesh, host and path, and the reporter sends transitions
|
|
302
|
+
only:
|
|
303
|
+
|
|
304
|
+
| Moment | Event |
|
|
305
|
+
|---|---|
|
|
306
|
+
| A target is first seen healthy | none |
|
|
307
|
+
| A target fails, after being healthy or never seen | `error`: `MeshProbeUnhealthy` |
|
|
308
|
+
| A target is still failing | none |
|
|
309
|
+
| A target recovers | `info`: `MeshProbeRecovered`, in the same error |
|
|
310
|
+
|
|
311
|
+
Every server that observes the same target reports into the same error, with
|
|
312
|
+
`user.id` naming the server, so the affected-user count is the number of servers
|
|
313
|
+
that saw the failure. The triggering report is in `metaData.mesh`.
|
|
314
|
+
|
|
315
|
+
The transition memory lives in the process. After a restart, the first failure
|
|
316
|
+
seen is reported as new, and `runProbeRound` reports every failure it sees.
|
|
317
|
+
|
|
318
|
+
A recovered target is not closed in Bugsnag; its recovery event joins the error.
|
|
319
|
+
|
|
320
|
+
## Limits
|
|
321
|
+
|
|
322
|
+
- **It runs inside its host.** A server that is down observes nothing. That is
|
|
323
|
+
what the other servers in the mesh are for.
|
|
324
|
+
- **It does not detect absence.** A target that nobody reports on any more looks
|
|
325
|
+
the same as a quiet minute. This package probes and reports; it does not alert.
|
|
326
|
+
- **Every instance probes.** A server scaled to N instances sends N reports per
|
|
327
|
+
target per round. They collapse in the query.
|
|
328
|
+
- **It needs a Node process.** A static site has nowhere to run it and can only
|
|
329
|
+
be a target.
|
|
330
|
+
|
|
331
|
+
## Development
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
npm ci
|
|
335
|
+
npm run typecheck # sources and tests
|
|
336
|
+
npm test # node:test; loopback servers and stubs only, no network
|
|
337
|
+
npm run build # dist/esm (with types) and dist/cjs
|
|
338
|
+
npm run pack:check # what `npm pack` would ship
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
`PACKAGE_VERSION` in `src/version.ts` is maintained by hand; a test fails when
|
|
342
|
+
it drifts from `package.json`.
|
|
343
|
+
|
|
344
|
+
Publishing is described in [PUBLISHING.md](./PUBLISHING.md).
|