Probe protocol
How a remote probe and the core talk. The implementation is crates/probeward-server/src/probe/protocol.rs; this page and that module must agree. For operating probes see probes.md.
Transport, and why
The probe opens one TCP connection to the core's probe listener (PROBEWARD_PROBE_LISTEN), runs TLS 1.3 over it (rustls, no other versions), and then a WebSocket. Messages are JSON text frames, one message per frame. Binary frames carry only the chunks of an update file.
gRPC was considered. A WebSocket was chosen instead, because:
- The traffic is a long-lived, two-way session in which either side speaks first (the core pushes polls, assignments and acknowledgements; the probe pushes results and replays). A WebSocket is exactly that, with nothing to generate.
- It needs no code generation, no
protocin the build and no HTTP/2 stack beyond what the core already has, which keeps the static musl probe small and the build reproducible fromcargoalone. - JSON reuses the serde types the engine and the API already use (
PollOutcome,Credential), so a result is the same value on the probe, on the wire and in the engine. The volume (a few results per second per probe) does not need a binary encoding. - Versioning is explicit in the handshake (below) rather than implied by field numbers, so an incompatible probe gets a clear refusal instead of silently misread fields.
What gRPC would change: it would bring a schema file (.proto) that other languages can generate clients from, compact binary messages and HTTP/2 flow control per stream, and standard tooling for tracing and load balancers that understand it. It would cost protoc or a vendored generator in the build, a second set of message types beside the serde ones with conversions between them, and an HTTP/2 server on the probe listener. Nothing in the protocol depends on the transport beyond framing, so the messages below could move to gRPC streams later without changing what they mean.
Trust
- Core to probe. The core holds a probe CA (ECDSA P-256). At each start it issues itself a server certificate from that CA for the name
probeward-core. The probe trusts exactly that CA, which it pinned at pairing; it does not use the system trust store, so no public CA can impersonate the core. The name the probe dials (PROBEWARD_PROBE_CORE_URL) is only where to connect. - Probe to core. Each probe has a client certificate signed by the probe CA. The core accepts a certificate only if its fingerprint is on the live trust list of paired, unrevoked probes; anything else fails the TLS handshake. Revoking takes the fingerprint off the list and closes the probe's session.
- Pairing token.
PWP1-<secret>-<pin>: 20 random bytes and the first 20 bytes of the SHA-256 fingerprint of the CA certificate, both base32. The core stores only the SHA-256 of the secret. The pin lets the probe verify the core on its very first connection.
Paths
| Path | Client certificate | Purpose |
|---|---|---|
/probe/v1/pair | none | Exchange a pairing token and a certificate request for a certificate. |
/probe/v1/session | required | The session. |
The v1 in the path names the URL layout, not the message protocol version; the message protocol is negotiated in hello.
Pairing
The probe connects without a client certificate, checks the server certificate against the pin in the token, and sends one message:
{"token": "PWP1-...", "csr": "<PKCS#10, DER, base64>", "version": "0.2.0", "target": "x86_64-unknown-linux-musl"}The core answers once and closes:
{"type": "paired", "probe_id": "...", "probe_name": "Branch", "certificate": "<DER, base64>", "ca": "<DER, base64>", "now": "2026-11-28T10:00:00Z"}
{"type": "refused", "reason": "the pairing token is unknown, expired or already used"}The core sets the certificate's subject itself; nothing in the request but the public key is used. The token is used up in the same transaction that stores the certificate's fingerprint. The probe checks that ca matches the pin before writing its identity.
Session
Handshake and version negotiation
The probe's first message is hello:
{"type": "hello", "min_protocol": 1, "max_protocol": 1, "version": "0.2.0", "target": "x86_64-unknown-linux-musl",
"buffer": {"samples": 0, "bytes": 0, "cap_bytes": 268435456, "lost": 0, "lost_from": null, "lost_until": null},
"now": "2026-11-28T10:00:00.120Z"}Each side has a range of protocol versions it speaks. The session uses the highest version in both ranges. If there is none the core answers refused with code incompatible_version and a reason that names both ranges, for example "incompatible protocol: the probe speaks 3 to 4, this core 1 to 2", records the refusal on the probe (shown in the UI and the API) and opens the probe incident at once, without the grace period. The probe logs the same reason and retries after five minutes. If the core has a binary for the probe and its auto-update is on, the refusal carries an update offer, so an old probe can update itself into compatibility (see updates).
Otherwise the core answers:
{"type": "welcome", "protocol": 1, "core_version": "0.2.0", "probe_id": "...", "probe_name": "", "now": "2026-11-28T10:00:00.100Z"}followed by the probe's assignment. A new session for a probe replaces any older one, which is closed with refused, code replaced.
Other refusal codes: revoked (the probe was revoked or deleted), unknown (no such probe), protocol (the first message was not hello).
Version rules
- A message type or a field may be added without a new version if an older peer can ignore it. Unknown fields are ignored; optional fields default.
- Removing or renaming a field, changing its meaning or type, or adding a message an older peer must understand, needs a new version. The core then keeps the old version in its accepted range for at least one release, so probes can be updated after the core.
- The core never refuses a probe whose range overlaps its own. The range of this build is
MIN_PROTOCOL_VERSION..PROTOCOL_VERSIONinprotocol.rs; it is 1..1.
Messages from the core
| Type | Fields | Meaning |
|---|---|---|
welcome | protocol, core_version, probe_id, probe_name, now | The session is open. |
refused | code, reason, update | The session is not accepted, or is being closed. |
assignment | revision, sensors, concurrency, credentials | The full set of sensors the probe runs; replaces the previous one. Sent after welcome and whenever it changes. |
poll | poll, sensor, reason, started, deadline | Poll this sensor now; reason is scheduled, scan_now and the like. |
cancel | sensor, poll | Stop that poll; its result is no longer wanted. |
ack | seqs (inclusive ranges) | These buffered samples are stored (or deliberately refused); forget them. |
ping | nonce, now | Keep-alive and clock sample; answer with pong. Every 15 s. |
update | version, target, sha256, size | An update is available. |
update_end | version | The update file's binary frames are complete. |
An assigned sensor carries id, device, kind, params, address, hostname, interval_ms, timeout_ms, offset_ms (its fixed place within the interval, the same the core uses), paused, and the ids of its inherited credentials: snmp_credential, ssh_credential, windows_credential, radius_credential, vsphere_credential, tls_client_credential, secret_credential and login_credential (the last six added within version 1 as optional fields, so a probe that predates them reads them as absent). credentials holds the values of those the sensor's kind uses. The values are sent only on this mutually authenticated session, are never written to disk by the probe, and are not included in logs (their debug form is redacted). Push sensors are never assigned: their reports go to the core.
halted (added within version 1, absent when empty) lists the spans {from, until} in which the sensor is outside its monitoring schedule or inside a maintenance window that stops polling, sorted and not overlapping, from the start of the core's UTC day for eight days. While it has no session the probe skips every slot of its grid inside a span, as the core would; at the first slot at or after until it polls again. The list changes, and the assignment is sent again, when a schedule or window changes and once a day. A pause is not in it: paused covers that. A probe that predates the field polls those slots and the core keeps what it replays as history only, so nothing opens or pages either way.
Messages from the probe
| Type | Fields | Meaning |
|---|---|---|
hello | see above | Opens the session. |
result | sample | The result of a poll. |
replay | samples | Buffered samples, oldest first, at most 200 per message. |
status | buffer, clock_offset_ms, skipped_polls | Every 10 s. |
pong | nonce, now | Answer to ping. |
update_fetch | version | Send me the offered update. |
update_result | version, ok, message | What became of an update; sent at the next connect after it. |
A sample:
{"seq": 4711, "id": "0193...", "sensor": "0193...", "poll": "0193...", "started": "2026-11-28T10:00:00.250Z",
"finished": "2026-11-28T10:00:00.262Z", "outcome": {"result": "ok", "channels": [{"key": "response_time", "value": 12.0}]}}idandstartedare fixed when the probe polls and never change however often the sample is sent.startedandfinishedare in core time (see the clock rule) and whole milliseconds, so the value survives every round trip exactly.pollis the core's poll id for a live result, andnullfor a poll the probe scheduled itself while it had no session.seqis the probe's buffer sequence number;ackrefers to it.
Live results and replay
Every sample is written to the probe's buffer before it is sent, live or not. The core acknowledges a sample only after it is committed to the database, so a sample is either stored or still on the probe.
A result for a poll the core is still waiting for is evaluated by the engine like a local result. A result for a poll the core has already given up on (the timeout passed, or the session that asked for it ended) is acknowledged and dropped: the engine has already recorded that poll's outcome.
replay samples go to history only: the engine does not evaluate them, so they cannot open, close or notify about incidents, and they do not change the sensor's current status. The core stores a sensor's sample for a given started once; a second copy is acknowledged and counted as a duplicate. A sample stamped more than 60 s after the core's current time, older than the history retention, or of a sensor the core no longer has, is acknowledged and counted as refused.
If an acknowledgement does not arrive within 30 s the probe sends the batch again.
Keep-alive and loss
The core pings every 15 s and drops a session that sends nothing for 45 s. The probe drops a session that receives nothing for 60 s. After a dropped session the probe reconnects with back-off from 0.25 s, doubling, to 30 s. When the core loses a probe's session it waits for the grace period before declaring the probe lost; revocation and an incompatible version skip the grace period.
Clock rule
The core's clock is the reference. The probe computes offset = probe_now - core_now from the now of welcome, of each ping and of the pairing answer (the one-way network delay is not corrected for; it is far below the resolution that matters for monitoring), keeps the latest estimate on disk, and subtracts it from its own clock for every timestamp it sends. It reports the estimate in status; an offset beyond 2 s is shown as a warning.
Updates
- The core sends
update(or includes the offer inrefusedfor an incompatible probe) when itsmanifest.jsonnames a newer version with a file for the probe's target, and auto-update is on for that probe. - A probe with updates allowed answers
update_fetchwith the version. - The core sends the file in binary frames of up to 64 KiB, then
update_end. - The probe checks the size and SHA-256 from the offer, test-runs the file, swaps it in and restarts. It reports the outcome with
update_resulton its next session. A version that failed is not fetched again until the probe restarts.
Limits
- WebSocket messages up to 64 MiB, frames up to 16 MiB (the library defaults). An assignment for a few thousand sensors is well under 1 MiB.
- At most
concurrency(64) polls run at once on a probe.