Log transport, storage and search¶
Transport¶
POST /api/v1/logs on the agent listener, authenticated with the device certificate like
every agent request. The body is {"lines": [...], "dropped": n}, gzip encoded, at most
4 MiB decompressed and 2000 lines; a message is cut at 8 KiB.
Backpressure: the server answers 429 with Retry-After when a device sends more than 30
batches a minute or a device or tenant reached its daily quota (until midnight UTC), and
503 while the disk guard refuses new lines. The agent waits as told and keeps its spool.
Storage on the server¶
device_logs holds time, device, tenant, source (journald, container, file), unit
(unit, container name or file path), priority 0 to 7, host, message and the extra fields
as JSONB. It is partitioned by day (device_logs_YYYYMMDD, UTC). Indexes: tenant and time,
device and time, tenant, unit and time, and a trigram index on the message (pg_trgm)
for text and regular expression search. Without the pg_trgm extension (it is a trusted
extension, the database owner can create it) the schema leaves the trigram index out and
text search scans the time range.
The logs job runs on one server instance:
- creates the partitions of the retention window and two days ahead,
- archives finished days when archiving is on (Archive),
- drops the partitions older than the retention (dropping a partition is cheap and leaves
no bloat). With archiving on, a day is only dropped when every tenant of that day has
a verified archive with the same number of lines; otherwise it stays and a notification
(
logs.guard) says why, - evaluates the alert rules every minute.
Retention, quotas and disk guard (Settings, Logs)¶
| Setting | Default | |
|---|---|---|
| Days on the server | 7 | 1 to 90 |
| Maximum store size | none | GB of all log partitions with indexes; above it new lines are refused |
| Minimum free disk | none | percent free on the database disk; checked where the server can read the database's data directory (same host and a role allowed to read data_directory) |
| MB per device and day | 200 | server side quota on top of the agent's own limit |
| MB per tenant and day | none | with overrides per tenant |
| Helpdesk reads device logs | off | see Access |
When the disk guard trips the server answers 503 to new batches, the devices keep their
lines in their spool, and a logs.guard notification goes out.
Search¶
Logs searches every device of the caller's tenant and scope; the device page's Logs tab searches one device. Filters: time range (quick ranges or absolute), source, minimum priority, device, and the query language:
| Term | Matches |
|---|---|
word, "a phrase" |
the message contains it (case insensitive) |
/regex/ |
the message matches the regular expression (case insensitive, at most 200 characters) |
device:NAME |
device ID, host name, or the short name of an FQDN; * as wildcard |
tag:, blueprint:, os: |
devices with that tag, blueprint or OS ID (debian, fedora ...) |
source: |
journald, container (also docker, podman) or file |
unit:, container:, file: |
unit, container name or file path, * as wildcard |
host: |
the host name the journal recorded |
prio:err, prio<=warning, prio>3 |
priority by name or number (0 emerg to 7 debug); prio<=err is err and more severe |
field.NAME:value |
an extra field, e.g. field._PID:1234 or field.compose_project:paperless |
-term |
negation |
Search times measured with 5,000,000 lines of 2000 devices over seven days (PostgreSQL 19 on
a laptop, through the API): newest 200 lines 45 ms, a phrase over 24 hours 76 ms and over 7 days
236 ms, a rare word over 7 days 32 ms, unit and priority 46 ms, a regular expression over 24
hours 150 ms, one device over 7 days 2 ms, histogram of 24 hours 118 ms, histogram of a phrase
over 7 days 404 ms. Reproduce with LIMDM_TEST_LOG_LINES=1 go test -run TestLogSearchVolume -v
./internal/server on a test database.
Every search runs read only under a statement timeout of 20 seconds; a search that takes longer asks for a narrower range or filter. The page shows a histogram of lines per time bucket and priority (click a bar to zoom), the result list with virtual scrolling, the lines before and after a line on the same device (context), a live tail that polls with backoff and can be paused, saved views, a link to the current filter, and an export.
Export: the current filter as NDJSON or CSV, at most 100,000 lines, newest first. Every
export is audited (logs.export) with the filter.
Alert rules¶
An alert rule is a query, a threshold and a window: when at least threshold lines
matched in the last window minutes, a logs.alert notification goes to the channels
that subscribed to it (Settings, Notifications), at most once per window. Test counts
now and sends a test notification. Rules belong to the tenant that created them and count
only the devices of the account that saved it (its tenant and device scope, stored with the
rule); only a rule saved by an unscoped global administrator counts the whole installation.
Test counts with the scope of whoever clicks it. Notifications name the rule, the query
and the count, never the text of the lines.
Access¶
| Role | Reads |
|---|---|
| admin, auditor | every device of their tenant and scope, and the settings and archive state |
| helpdesk | one device at a time (the device tab), only when Helpdesk reads device logs is on, only devices of its scope |
API tokens follow the same rules by role and scope. Only global administrators change the settings, rotate the keys and start archive runs or restores; all of it is audited.