Log management¶
LiMDM collects the logs of managed devices without extra software on them: the agent reads the systemd journal, Docker and Podman container logs and plain log files, and ships them over its mTLS connection. The server keeps a searchable window (7 days by default) in PostgreSQL and can archive every day, encrypted, to an S3 compatible bucket or Backblaze B2. The console has a Logs page for the whole fleet and a Logs tab on every device page.
Collection is off until a com.limdm.logging item
enables it for a blueprint.
Data flow¶
journald ─┐
docker ───┼─ agent: filter, mask, rate limit ─ spool on disk ─ POST /api/v1/logs (mTLS, gzip)
files ────┘ │
server: quotas, dedup ─ device_logs (one partition per day)
│
console search, histogram, export, alerts daily archive ─ S3 / B2
- Every 30 seconds the agent reads what is new in each enabled source, drops what the
filters exclude, masks secrets, applies the rate limit and appends the lines to a
spool under
/var/lib/limdm/logs(mode 0700). - The spool is shipped segment by segment (at most 1000 lines or 256 KiB each). A segment is removed once the server answered; a batch lost on the way is sent again.
- The server stores each line once: the key is device, source and the cursor the agent sends (journal cursor, container and time, file inode and offset). A batch sent twice is stored once (at least once delivery, no duplicates).
Collection on the device¶
| Source | How | Cursor |
|---|---|---|
| journal | journalctl -o json --after-cursor=... with the units and minimum priority of the item |
journal cursor |
| containers | docker or podman ps and container inspect to pick the containers, then logs --timestamps --since per container |
time of the last line per container |
| files | read from the stored offset; complete lines only | inode and offset |
- Collection starts at the end of each source when it is first seen: the agent does not ship history from before the item was assigned (nor of a new container or file).
- File rotation: when the inode changes, the rest of the old file is read from
<path>.1when it was renamed there, then the new file from its start. A file that got shorter (copytruncate) is read from the start again. - Priorities: journal lines keep theirs. Container standard output is
info, standard errornotice; container and file lines that namepanic,fatal,crit,errororwarnearly in the text get the matching higher priority. - LiMDM's own lines (
limdm-*units,/var/log/limdm*) are never shipped, so shipping cannot feed itself. Shipping errors are logged once after three failures in a row. - The agent never restarts or reconfigures journald, Docker or Podman. Each read is bounded in time (30 s) and output, so a busy production host (Docker, Postfix) only sees a few short tool calls every 30 seconds.
File sources¶
The agent reads files as root, so a file source is held to these rules (on the server when the item is saved, and on the device before every read):
- An entry is a path, a pattern with
*and?(one path component each, as in/var/log/*.logor/srv/*/logs/*.log) or a directory ending in/for every file directly in it. A pattern must stay inside the allowed locations with every wildcard replaced by a plain name; the agent checks each match again like a plain path, skips rotated and compressed copies (x.1,x.2.gz,x-20261127) and links, and reads at most 200 files per entry. - Only below
/var/log/,/srv/<name>/log/or a custom root of the item (roots), clean absolute paths without wildcards. Secret locations are refused anywhere (/etc/shadow,/etc/gshadow,/etc/ssh/,/root/,/home/*/.ssh,/etc/ssl/private/,/var/lib/limdm/,/etc/limdm/,/proc,/sys,/dev,/run,/boot). - Custom roots (
roots) are for applications that log elsewhere, for example/opt/app/logs. A root must be a clean absolute directory at least two levels deep:/and bare top level directories (/etc,/home,/usr,/var,/opt...) are refused, so are roots in a secret location. A root must contain a path componentlogorlogs(or one ending in-log,_log,-logs,_logs), for example/opt/app/logsor/data/nginx-log; wide roots such as/var/libor/var/backupsnever pass. Name only directories that hold nothing but logs: the agent reads every declared file below them as root and ships it. Because a root widens what the agent reads, saving an item withrootsneeds four eyes approval when it is on, and the audit entry lists the roots. The server checks the rules when the item is saved, the agent again before every read. - Symbolic links of the directories are resolved and the real path must still be in an
allowed root; the file itself is opened with
O_NOFOLLOW(a link as the file is refused, also one pointing inside the root), and the opened file must be the file the real path names (same device and inode), so it cannot be swapped between the checks and the read. - Neither the file nor its directory may be writable by group or others unless root owns
it (
/var/logowned by root with group write, as on Ubuntu, is fine). A log directory of a service user that others can write to is refused: make it0755or move the log. - A refused file is skipped silently on the device (no lines, no error loop); check the path and the modes when a file source stays empty.
Filters, masking and limits¶
includeandexcludeare regular expressions on the message.- Masking runs on the device before a line is stored in the spool. The built in rules
replace passwords, tokens and keys in
key=valueandkey: valueform, the value ofAuthorizationheaders, PEM private keys, JWTs, AWS access key IDs and credentials in URLs with***;maskadds own expressions. Masking cannot know every format: check a sample of the shipped lines before rolling a source out widely. lines_per_second(default 20, bursts of ten seconds) andmb_per_day(default 100) bound what one device sends; lines over the limits are dropped and counted.buffer_mb(default 32) bounds the spool while the server is not reachable. When it is full the oldest segment is removed and its lines are counted as dropped. Dropped lines are reported with the next batch and shown per day in Settings, Logs.
Personal devices¶
A device is personal when it has the tag personal or the custom attribute
ownership=personal. On personal devices the server switches every logging item off
unless the item sets allow_personal. Use that only with the consent the applicable law
and works agreements require.