Skip to content

feat: nrc monitor (every Norcube Monitor operation) - #15

Merged
jansvabik merged 6 commits into
mainfrom
feat/monitor
Nov 4, 2026
Merged

jansvabik merged 6 commits into
mainfrom
feat/monitor

Conversation

@jansvabik

Copy link
Copy Markdown
Member

What

nrc monitor: every Norcube Monitor operation an organization member has, following DESIGN.md 6.1 (steps 5 to 10 and 14). The product was called PulseCheck until the backend renamed it before launch (jetlio/norcube-platform-backend-mono#159); this PR replaces #14 and carries its commits plus the rename. Needs the backend's Monitor scopes for CI use; signed-in people can use it as soon as the endpoint is live. The client is generated from #159's spec.

Names

Value
Product Norcube Monitor
Command group monitor
Registry key, --endpoint-url key monitor (NORCUBE_MONITOR_URL)
OAuth audience monitor
Scopes monitor.read, monitor.check, monitor.write, monitor.channels
Endpoint https://monitor.api.norcube.com/app/v1
Spec, generated package apps/monitor/docs/app_swagger.json → specs/monitor.openapi.json, internal/api/monitor

No pulsecheck alias or cmdutil.Renamed entry: the old name was never in a release, so no script, config file or token depends on it (decision-log entry in DESIGN.md).

Commands

  • status (--fail-on critical|warning|none, default none; exit 1 with the new code unhealthy, report printed either way)
  • monitors list | get | create | update | delete | pause | resume | run; monitors bulk pause | resume | delete; monitors results list, status-changes list (alias history), stats get, availability get, certificate get, alerts get | set
  • incidents list | get | acknowledge (ack) | summary
  • channels list | get | create | update | delete | test | verify; channels deliveries list

Monitors and channels are named by id or exact name (ambiguous names are a usage error). monitors run --wait turns the synchronous check's verdict into the exit code (job_failed on critical or inconclusive; --fail-on warning; exit 7 after --wait-timeout). CI tokens: monitor.read, monitor.check, monitor.write, and monitor.channels for alert channels (not included in monitor.write). Secrets: secret headers only from a file or stdin, Slack/Discord URLs only via --url-file, a webhook's signing secret only to --secret-file (0600, never overwritten, never printed), verification codes via a hidden prompt or --code-file.

Shared changes (additive)

  • apierror parses RFC 9457 problems (detail, field errors, reason; INSUFFICIENT_SCOPE → exit 5); details in -o json errors.
  • clierr.CodeUnhealthy (exit 1).
  • output.Object.Text: a fixed -o text record for objects whose fields depend on the resource.
  • Table colours for Monitor's status words (Up, Down, Valid, Expiring, ...).
  • New P1 verbs acknowledge, verify, summary (DESIGN.md), decision-log entries, inventory, 6.1 state.

Codegen

make codegen MONO=<backend at #159> regenerates specs/monitor.openapi.json and internal/api/monitor; against the previous spec only the title, scope names in x-norcube-scopes and one example URL change (the client differs in two comment lines). make codegen also shows drift in billing, domainradar and langsync: it is pre-existing and left out of this PR on purpose.

Goldens

Renamed pulsecheck-* → monitor-* and commands-pulsecheck.json → commands-monitor.json. Content differs only by the name; monitor-channels-list.txt has one column two characters narrower because a fixture URL got shorter. commands-billing.* lists the service key monitor in --endpoint-url's description.

Not verified against a live service

No credentials were used: everything is tested in-process against the fake backend (golden files in all four formats for every read command, command tests for every write and the key errors, commands-monitor.json).

Checks

go build, go vet, go test -race ./..., go mod tidy -diff, scripts/govulncheck.sh, golangci-lint v2.12.2 (0 issues). make docs generates 206 reference pages, 43 of them monitor-*, none naming PulseCheck (not committed in the docs repo).

Registry entry pulsecheck (Norcube PulseCheck, audience pulsecheck,
https://pulsecheck.api.norcube.com/app/v1, spec apps/pulsecheck/docs/
app_swagger.json), so `nrc api pulsecheck`, --endpoint-url pulsecheck=...
and NORCUBE_PULSECHECK_URL work. The hand-kept tables get it too: the
config switch, the service key constant, the audience constant, `auth
token --audience pulsecheck` and the CI token audiences.

The client is generated from the spec that adds operation ids, security,
problems and x-norcube-scopes to every operation; the Status tag (the
public service status route) is excluded.

Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
…er has

- status: open incidents, monitors by status and the ones that need
  attention; --fail-on critical|warning exits 1 with the new code
  unhealthy (the report is printed either way).
- monitors list|get|create|update|delete|pause|resume|run, bulk
  pause|resume|delete, results list, status-changes list, stats get,
  availability get, certificate get, alerts get|set. Typed flags per type
  (http, keyword, ssl, domain) or the API body with --from-file; secret
  headers only from a file or stdin; update starts from the current
  settings. Monitors are named by id or exact name. run --wait makes the
  check's verdict the exit code (job_failed, --fail-on warning).
- incidents list|get|acknowledge|summary with every API filter.
- channels list|get|create|update|delete|test|verify, deliveries list. A
  webhook's signing secret goes to --secret-file and is never printed;
  Slack and Discord URLs come from a file or stdin; verify asks for the
  code on a terminal or reads --code-file.
- Completion for monitor, channel and incident ids.

The shared error formatter reads RFC 9457 problems (detail, field errors,
reason INSUFFICIENT_SCOPE to exit 5, the rest in details).
output.Object.Text keeps -o text columns fixed for objects whose fields
depend on the resource, and tables colour PulseCheck's status words.

Tests: golden files in every format for each read command, the command
tree of the group, and command tests for every write, the usage errors
before any request, confirmations, name resolution, --wait outcomes,
secrets kept off stdout and the problem mapping.

Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
The backend adds pulsecheck.channels: CI tokens and scoped sign-ins can
manage alert channels, send test alerts and verification codes with it,
and pulsecheck.write doesn't include it. Help text, DESIGN.md and the
changelog say so instead of calling channels person-only; the spec is
regenerated (x-norcube-scopes only, the client is unchanged), and a test
pins that a refusal naming the scope exits 5.

Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
The backend renamed the service before its first release, every
technical name included, and the CLI follows: command group `monitor`
(`nrc monitor monitors list`, `nrc monitor status`), registry key,
OAuth audience and generated package `monitor`, scopes
`monitor.read|check|write|channels`, endpoint
https://monitor.api.norcube.com/app/v1 and `NORCUBE_MONITOR_URL`.

The client and spec are regenerated from the renamed backend; only
names in descriptions and examples change. The goldens differ only by
the name (and one table column that got narrower with a shorter
fixture URL).

No `pulsecheck` alias: the old name was never released, so no script,
config file or token depends on it.

Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
Signed-off-by: Jan Švábík <jansvabik@jansvabik.cz>
@jansvabik
jansvabik merged commit d3db56a into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant