Monitoring and audit log
Watch Pratique with its health endpoints and Prometheus metrics, receive alerts in your chat, prove that the audit log was not changed, and export compliance reports.
Health checks
| Endpoint | Answers | Use it for |
|---|---|---|
/healthz | ok while the process runs. | Liveness checks. |
/readyz | ready, or HTTP 503 with database unavailable or storage unavailable. | Readiness checks and load balancers. |
/metrics | Prometheus metrics, only with the metrics token. | Monitoring and alerts. |
/readyz does not check the public registries on purpose. When a registry is down, Pratique can still
serve the files it has stored, so a restart would not help.
Container images without a shell can use pratique healthcheck. The Docker image already does this every
30 seconds. See healthcheck.
Metrics
/metrics is off until you set PRATIQUE_METRICS_TOKEN. Without the correct token, it answers
HTTP 404. Send the token as a bearer token:
curl -H "Authorization: Bearer $PRATIQUE_METRICS_TOKEN" https://pratique.example.com/metrics
scrape_configs:
- job_name: pratique
scheme: https
authorization:
credentials: YOUR_METRICS_TOKEN
static_configs:
- targets: ["pratique.example.com"]
| Metric | Type | Value |
|---|---|---|
pratique_events_total{action="..."} | counter | Audit log events by action, such as cleared, held, refused and flagged. |
pratique_incidents_open | gauge | Incidents waiting for review. |
pratique_requests_pending | gauge | Exception requests waiting for a decision. |
pratique_artifacts | gauge | Cached upstream files. |
pratique_artifact_bytes | gauge | Size of the cached upstream files. |
pratique_private_files | gauge | Published private files. |
pratique_feed_last_sync_timestamp_seconds | gauge | When the OSV threat feed last synced, as a Unix time. |
Suggested alerts
- Open incidents:
pratique_incidents_open > 0. - Not ready:
/readyzfails from outside. - Stale threat feed:
time() - pratique_feed_last_sync_timestamp_seconds > 3600. The feed syncs every 5 minutes. When it stops, the hourly recheck still runs, but new malware reports take longer to arrive. - Waiting requests:
pratique_requests_pending > 0for longer than your review target. - Storage growth:
pratique_artifact_bytesnear your disk size. See storage and backups.
Webhook alerts
Set PRATIQUE_WEBHOOK_URL (server.webhook_url) to receive alerts. Pratique sends one for:
- Each new incident.
- Each new exception request, and each decision on one.
- Exceptions that end soon.
- AI assessments of suspicious or malicious, and AI holds. See AI triage.
- The daily audit anchor. See anchors.
Message format. Every message is JSON with a text field, so Slack incoming webhooks
work as they are. For any other host, the JSON also has title and body, so you can format the
message yourself. Pratique escapes <, > and & in text, so
a package name cannot become a link or a mention in chat.
{
"text": "Pratique incident: ...\n...",
"title": "Pratique incident: ...",
"body": "...\nhttps://pratique.example.com/incidents"
}
Retries. Pratique tries each message up to three times, 5 and then 10 seconds apart. A response with a status below 300 counts as delivered. Retries are kept in memory, so a message can be lost if the server restarts during an outage of the webhook. The incident itself is stored either way, so check the Incidents page after any downtime.
Audit log
Every decision, download, setting change and sign-in goes into the audit log. The log is a hash chain: each event's hash covers its contents and the hash of the event before it. Editing, inserting or removing an event breaks every hash after it.
Sign the log
Someone with write access to the database could rebuild the whole chain. To stop that, sign each event with a key that the database never sees:
pratique audit-keygen
# PRATIQUE_AUDIT_KEY=...
# Public key, for verify-log: ...
- Set
PRATIQUE_AUDIT_KEY(server.audit_key) on every replica. - Keep the key out of the database and out of its backups.
- Keep the public key in a different place, where the people who run the database cannot change it.
Events written before you set the key are not signed. Verification with a public key then fails at the first unsigned event, so set the key before the server goes into use.
Anchors
An anchor is the hash at the head of the chain at one point in time. When PRATIQUE_WEBHOOK_URL is set,
Pratique posts one each day, with the title "Pratique audit anchor", the number of events and the head hash. Keep
these messages somewhere the database's admins cannot change.
Verify the log
Run pratique verify-log on a machine that can read the database. It needs read access only.
pratique verify-log --public-key PUBLIC_KEY --anchor HEAD_FROM_AN_ANCHOR
# Audit log verified: 48210 chained events, 48210 signed, 0 from before the chain.
# Head: 3f9c...
| Flag | What it adds |
|---|---|
--public-key | Requires a valid signature on every chained event. |
--anchor | Requires that this earlier head is still in the chain. This detects removal of the newest events. |
--allow-legacy | Accepts events from before the chain existed, on a server that ran an older version. Those events cannot be checked. |
Without --public-key or --anchor, the command says which checks it did not do. On failure,
it names the first bad event, for example "event 812 was changed: its contents don't match its hash".
Keep events for a limited time
Events are kept forever by default. Set PRATIQUE_EVENTS_DAYS to remove older ones once a day. Each
removal adds a signed event that names the hash of the last removed event, and verify-log checks the chain
from there. A log cut without that record still fails. When you turn it on:
- An
--anchorolder than the cut can't be found, so use one newer than the retention period. - The first run on a large log removes many rows at once, and new events wait until it finishes. Turn it on at a quiet time.
- Who pulled a package, and the incident when a pulled version is reported later, come from this log. Keep the period longer than you want to look back, and export the log first if you need it longer.
What it proves
| Change made with database access | Without the signing key | Detected by |
|---|---|---|
| Editing, inserting or removing an event | Cannot re-sign the chain | --public-key |
| Removing the newest events | The shorter chain still looks valid | --anchor, back to when that anchor was published |
| Adding unchained events, or clearing every hash so the log looks older than the chain | Fails unless you pass --allow-legacy | Always |
Limits
- Events newer than the latest anchor can be removed without detection. That is up to one day of events. If that matters, send the log to another system as it is written.
- With
--allow-legacy, events from before the chain could have been added or changed. Only--anchorthen shows that the chain itself is intact. - On a server that never ran an older version, events "not protected by the chain" mean that someone probably changed the log.
- Someone who has the signing key, such as a person with access to the running server, can forge new events. The signature protects past records from database access. It does not protect against a full compromise of the server.
Compliance reports
The Reports page shows the policy in force and what it did over the last 30, 90 or 365 days. Only admins can see it. It covers:
- Quarantine windows, rules and teams with their own policy.
- Every exception in force, with its owner, reason and expiry.
- Counts of cleared, held and refused files, exception requests, projects and builds.
- Incidents in the period, tokens by kind, and the audit log's event count and head.
Rules and exceptions show what is in force now. Counts and incidents cover the chosen period.
Print the page or save it as a PDF, or select Download JSON. Each JSON download from the page is recorded in the audit log.
Keep copies on a schedule
pratique report prints the same report as JSON. Run it on the server, with the same settings as the
server, and store the output somewhere the server cannot reach:
pratique --config /etc/pratique/pratique.yaml report --days 90 > compliance-$(date +%F).json
--days takes 30, 90 or 365, and the default is 30. To prove the log behind a report was not changed,
run pratique verify-log and compare its head with audit_log_head in the report.