feat: show what the checker saw (HTTP evidence) #80

Merged
Sebi merged 4 commits from feat/check-evidence into main 2026-11-22 11:13:31 +00:00
Owner

Stacked on #78.

Recording (internal/check, used by HTTP, JSON and Prometheus checks)

  • Every request/response of the redirect chain with status, protocol and headers; timing per phase via httptrace (DNS, connect, TLS, waiting, download, total); remote address; leaf certificate (subject, SANs, issuer, validity, TLS version and cipher); first 32 KiB of the body (binary bodies are not kept, cut UTF-8 is trimmed); the stage a failed exchange stopped in.
  • Redaction in the checker: values of configured request headers, Authorization/Cookie, and Set-Cookie values (names kept).
  • The certificate is captured even when verification fails: verification moved into VerifyConnection (same checks as crypto/tls, tested against wrong host names and untrusted roots).

Transport and storage

  • agentapi.Result.Evidence (optional, backwards compatible). Checkers send it with failures, success/failure changes and otherwise every 10 minutes per monitor.
  • check_evidence table (RLS, cascades with monitors): latest success per monitor+region; failures unless the same error was kept within 5 minutes; UPTIME_RETENTION_EVIDENCE (30 days) via housekeeping; size and JSON validity checked on receipt.

Console and API

  • Monitor page (editors only): list of captured responses and a "details" link on matching recent checks.
  • Evidence page: timing bar, redirect chain with collapsible headers, certificate with days left, body as escaped text (JSON indented). Never rendered as HTML (tested with a script in the body).
  • GET /api/v1/org/monitors/:id/evidence[/:evidence]; readers get 403, as responses may contain personal data or secrets.

No browser rendering, as agreed.

Closes #79

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

Stacked on #78. **Recording** (`internal/check`, used by HTTP, JSON and Prometheus checks) - Every request/response of the redirect chain with status, protocol and headers; timing per phase via httptrace (DNS, connect, TLS, waiting, download, total); remote address; leaf certificate (subject, SANs, issuer, validity, TLS version and cipher); first 32 KiB of the body (binary bodies are not kept, cut UTF-8 is trimmed); the stage a failed exchange stopped in. - Redaction in the checker: values of configured request headers, Authorization/Cookie, and Set-Cookie values (names kept). - The certificate is captured even when verification fails: verification moved into `VerifyConnection` (same checks as crypto/tls, tested against wrong host names and untrusted roots). **Transport and storage** - `agentapi.Result.Evidence` (optional, backwards compatible). Checkers send it with failures, success/failure changes and otherwise every 10 minutes per monitor. - `check_evidence` table (RLS, cascades with monitors): latest success per monitor+region; failures unless the same error was kept within 5 minutes; `UPTIME_RETENTION_EVIDENCE` (30 days) via housekeeping; size and JSON validity checked on receipt. **Console and API** - Monitor page (editors only): list of captured responses and a "details" link on matching recent checks. - Evidence page: timing bar, redirect chain with collapsible headers, certificate with days left, body as escaped text (JSON indented). Never rendered as HTML (tested with a script in the body). - `GET /api/v1/org/monitors/:id/evidence[/:evidence]`; readers get 403, as responses may contain personal data or secrets. No browser rendering, as agreed. Closes #79 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added this to the M6 Admin UI milestone 2026-11-22 11:10:00 +00:00
Sebi changed target branch from feat/prometheus to main 2026-11-22 11:11:30 +00:00
Sebi added 11 commits 2026-11-22 11:11:30 +00:00
Refs #27

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
A heartbeat monitor has a secret ping URL instead of a target and
regions. Jobs call it with GET, HEAD or POST after each run, or /fail
with an optional message. When no ping arrives within the interval plus
a grace period, a failure is recorded and evaluated like a checker
result, so confirmations, maintenance and notifications apply. One API
replica at a time checks deadlines. The URL is shown only to members who
may edit the monitor, since it can report the job healthy.

Closes #27

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
The serializer checked the disabled property, which only reflects a
field's own attribute, so settings of other monitor types were sent too
and fields with the same name overwrote each other. Forms also gain
arrays from numbered names and header lines. Browser tests now run every
page in testdata, with a time limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
A JSON check requests a URL with GET or POST, optional headers and body,
and requires the expected status and every condition: paths like
checks[0].state compared with ==, !=, <, <=, >, >=, contains, exists or
absent. Failures name the path, the value found and the expectation.
HTTP and JSON checks share the request code and its network guard.

Refs #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Readers no longer see request header values, which typically hold
credentials.

Closes #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
A Prometheus check runs an instant query against the query API of
Prometheus or a compatible server and requires every series, or at least
one, to meet the condition. No data fails unless allowed. Failures name
the series, its value and the expectation; query errors are passed on.

Refs #25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Closes #25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
With Spec.Capture, HTTP, JSON and Prometheus checks record every request
and response of the redirect chain, the time spent per phase, the remote
address, the server certificate and the first 32 KiB of the body.
Configured headers, credentials and cookie values are redacted. The
certificate is recorded before verification, which is now done in
VerifyConnection the way crypto/tls does it, because crypto/tls drops the
certificate exactly when verification fails.

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
The API keeps the latest success per monitor and region and failures,
thinned to one per five minutes while the error stays the same, for
UPTIME_RETENTION_EVIDENCE (30 days). Monitor pages link evidence from
the recent checks; a page shows timing, redirect chain with headers,
certificate and the body as text. Readers see none of it, since
responses may contain personal data or secrets.

Closes #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 34135ef2e5 into main 2026-11-22 11:13:31 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#80