Liveness and readiness are not the same question
They are separate endpoints because they answer separate questions, and conflating them causes an outage rather than preventing one./health checks nothing, deliberately
/ready checks the dependencies
/health, readiness on
/ready. Pointing liveness at /ready reintroduces exactly the failure mode
/health exists to avoid.
/api/v1/system/status
The authenticated view, and the one that tells a user something the probes
cannot: whether the advisory data behind their results is trustworthy.
Everything it reports is the caller’s own tenant’s: queue depth, scan
counts, overdue schedules. A global queue depth would be more useful to an
operator and would also tell every customer how much work every other customer
is doing, which is a business disclosure wearing an operations badge. Global
figures belong in metrics, behind an operator’s own authentication.
It also names the build that answered, under version: version,
commit, build_time and modified (a build from an uncommitted tree). The
dashboard shows the same thing at the foot of Settings, which is the
quickest answer to “which version is this deployment on?” for a support
ticket.
A tenant’s status is reported unhealthy when the advisory data is not
trustworthy. Reporting the process healthy while it can only produce results it
has to caveat would make the endpoint agree with the failure it exists to catch.
See Vulnerability database.
The scanning engine is never named in the payload. A CI guard fails the build if
its identity reaches the API layer, and a test asserts the same thing about the
response body.
Metrics
Why it is a separate, private listener
Metrics are cross-tenant aggregates: how many scans run, how many findings exist, how often authentication fails. Every one of those is a fact about the business rather than about a tenant, so none of them belongs on a customer-facing API even behind an authorisation check. TRUSTIVAN has no operator plane, and inventing one purely to guard a route would be a worse answer than not exposing the route publicly. So the metrics live on their own listener, bound to loopback. Binding this to0.0.0.0 publishes those aggregates to anything that can route
to the host. If you need remote scraping, route to it deliberately (through a
sidecar, an overlay network, or an authenticating proxy) rather than by widening
the bind address.
Gauges are refreshed on a timer, not computed on scrape
Values are refreshed every 30 seconds by a periodic task rather than queried during a scrape. A collector that queries the database while Prometheus is scraping turns an unreachable database into a hung scrape, so monitoring goes blind at exactly the moment it is needed, and it lets anyone who can reach the port generate database load. The cost is that a gauge can be up to 30 seconds behind, which is the right trade for a number you alert on over minutes.Label cardinality is a hard constraint
A Prometheus label with unbounded values is not a slow query, it is an out-of-memory: every series is retained. Route labels therefore use the registered pattern (/api/v1/findings/:id), which is the difference between a dozen series and one
per finding ever viewed. Unmatched requests collapse to a single label, because
a 404 sweep is exactly the traffic that would otherwise mint a series per URL an
attacker tries. A test asserts that no metric carries a tenant, user, finding,
asset or image label.
If you add a metric, that constraint applies to you too.
What is exported
All metrics are prefixedtrustowl_.
The pool figures and the rate-limit rejections are the saturation and error
halves of a utilisation/saturation/errors view: a pool whose wait count is
climbing is the database becoming the bottleneck before latency says so, and
a burst of
429s is a caller being refused, which no latency figure shows.
The metric worth alerting on
trustowl_scheduler_lag_seconds.
It is the one that says the scheduler has stopped, which a queue depth of
zero cannot: a dead scheduler produces no work, so every other figure then looks
healthy. An empty queue and a broken scheduler are otherwise indistinguishable.
Alongside it, worth watching:
- Queue depth trending up while worker count is flat: add worker replicas, see Scaling.
- Scan failure rate, which distinguishes a registry problem from a capacity problem.
- Anything indicating the vulnerability database is ageing past
VULN_DB_MAX_AGE_HOURS, which means blocked egress, a stale mirror, or a cache directory that is not actually persisted.
Tracing
Spans are created throughout both the request and the scan pipeline (HTTP
handler, service, repository, scanner engine, job worker) regardless of
this setting: leaving it unset means nothing is ever exported, not that
nothing is instrumented. There is no separate
TRACING_ENABLED flag; the
endpoint IS the switch, so there is exactly one way to misconfigure this (a
typo’d host) rather than two.
Export is OTLP over gRPC without TLS, every span sampled, with the
service named trustowl-api or trustowl-worker. Point it at a collector
on the same host or private network (a sidecar or node-local OpenTelemetry
Collector), and let that collector forward over TLS if your backend is
elsewhere. Setting OTEL_EXPORTER_OTLP_INSECURE=false does not switch this
exporter to TLS. A collector that is unreachable at startup is logged and
skipped; the process still serves.
On Docker Compose, set the variable in the stack’s env file; on Kubernetes, in
the trustowl-config ConfigMap. Both deployment files pass it to the API and
the worker.
Every log line written inside a span carries that span’s trace_id and
span_id, whether or not anything is exported. The API’s http request line
has them, and so do a scan’s log lines, so a trace found in your backend leads
to its log lines with one filter:
tenant.id once a request or scan is attributed to one,
and a scan’s spans additionally carry scan.id. Never a secret, customer
code, or scanned content, which is the same rule the metrics labels above
follow, for the same reason: a trace is retained and read by whoever operates
the collector, which for a self-hosted deployment is a third party more often
than not.
Logs
Both processes log structured events. Three lines worth recognising:
Failure messages stored on a scan are sanitised before they are written, because
they are returned by the API: registry client errors routinely embed the URL
they were fetching, and a registry URL can carry a bearer token in a query
parameter. Anything matching a marker is replaced wholesale rather than trimmed
(trimming invites a near-miss that leaks the tail of a token), control
characters are stripped so an error cannot forge extra log lines, and the
message is capped at 300 characters.
What is not here yet
Running Prometheus, Alertmanager and Grafana
The alert rules (19) and a Grafana dashboard ship ininfra/monitoring/ in the
repository (alerts.yml, dashboard.json). On Docker Compose they are loaded
by an opt-in profile of the production file:
monitoring.sh up starts the four services below and then checks what the
alerts depend on, exiting non-zero if any is untrue: every rule in
alerts.yml loaded, every scrape target up, and the backup result series
visible. It refuses to start with the example Alertmanager file, whose
receivers reach nobody. monitoring.sh status repeats the checks;
monitoring.sh down stops the four services.
On a local production-shaped stack (2026-11-11) it reported 19 of 19 rules,
node, prometheus, trustowl-api and trustowl-worker up, and
trustowl_backup_success scraped. Stopping the API then fired
TrustOwlAPIDown in that Prometheus and Alertmanager; see the
incident runbook.
The rules are also unit-tested: infra/monitoring/alerts.test.yml feeds
TrustOwlAPIDown and TrustOwlBackupFailed a series and expects each to go
pending, fire and resolve (promtool test rules alerts.test.yml, run in CI by
make ci-deployment). A rule that parses but matches nothing fails there.
All three listen on loopback only. Prometheus has no authentication and its
samples describe every tenant, so reach them through an SSH tunnel rather than
publishing them. Leave the profile off if you already run Prometheus, and
scrape
api:9090 and worker:9090 from it instead.
Check that it is doing what the table says, not only that the containers are
up:
lastError in the same /api/v1/targets
answer. The job labels matter: the rules match trustowl-api and
trustowl-worker by name, so a Prometheus of your own that scrapes the same
ports under other job names collects every sample and can never fire those two
alerts.
On Kubernetes no monitoring stack is deployed for you; bring a Prometheus in a
namespace called monitoring, which is the one the NetworkPolicy admits to the
metrics port.
One host, several stacks
A host that runs more than one stack (production, a demo and a sandbox, say) should not run the profile above once per stack.infra/docker/monitoring.yml
is one monitoring stack for the whole host, started and verified by
infra/scripts/monitoring-host.sh up:
- Prometheus scrapes every stack’s API and worker, labelled with the
stack, plus the host (node-exporter: CPU, memory, disk) and every container
(cAdvisor), and loads
alerts.ymlwithhost-alerts.yml(public probes, disk and memory, container memory limits, WAL archiving and its drill). - Alertmanager e-mails through the product’s own SMTP settings, read from
the stack’s env file, and posts to
ALERT_WEBHOOK_URLwhen set (Slack incoming-webhook URLs get Slack’s format). It refuses to start with neither. - A status checker probes each public component every minute and writes a static status page with 90 days of measured uptime and incidents.
infra/scripts/monitoring-host.sh test-alert raises a real alert through the
whole path and waits for its notification and its resolution to be delivered.
See Service level objectives for the thresholds the rules
encode.
Next
- Upgrades: what to watch during one.
- Troubleshooting scans: when a symptom is a scan rather than the platform.