This episode builds observability for containers: runtime status with lxc-info, resource monitoring via cgroup, Prometheus integration (node_exporter per container) and Zabbix, plus LXC logs in /var/log/lxc/, per-container journal, and boot logs.

You now have many containers, and "many" means they need eyes that keep watching. In episode 20 we build observability: viewing runtime status, monitoring per-container resources, connecting to popular monitoring systems (Prometheus/Zabbix), and reading logs correctly. Without this, you'll only know a container has a problem when a user reports it.
The fastest command to see a container's state:
lxc-info -n c1
lxc-ls -flxc-info -n c1 -s shows a concise state summary — useful in scripts:
lxc-info -n c1 -sFor a simple monitoring script:
if [ "$(lxc-info -n c1 -s | awk '{print $2}')" = "RUNNING" ]; then
echo "c1 UP"
else
echo "c1 DOWN"
fiThe true resource numbers live in the cgroup (episode 7). Read them directly for accurate values:
cat /sys/fs/cgroup/lxc/c1/memory.current
cat /sys/fs/cgroup/lxc/c1/memory.max
cat /sys/fs/cgroup/lxc/c1/cpu.maxsystemd-cgtopsystemd-cgtop shows live CPU/memory usage per cgroup — the fastest tool for finding a container that's "eating" resources.
Tip
The most accurate way to measure "a container that has exceeded its limit" is comparing memory.current vs memory.max, and checking whether memory.events records oom_kill. A rising oom_kill count is a sure sign processes inside the container are being killed for exceeding the memory limit (episode 7).
The simplest way to monitor containers with Prometheus: run node_exporter inside each container, then have Prometheus scrape each container's IP. Containers using systemd can run it as a regular service.
lxc-attach -n c1 -- apt install prometheus-node-exporter
lxc-attach -n c1 -- systemctl enable --now prometheus-node-exporterscrape_configs:
- job_name: "lxc-containers"
static_configs:
- targets:
- "10.0.3.10:9100" # c1
- "10.0.3.11:9100" # c2
labels:
group: "homelab"node_memory_MemAvailable_bytes vs the container limit.node_cpu_seconds_total for load patterns.node_filesystem_avail_bytes for disk inside the container.If you don't want an agent in every container, scrape from the host via cgroup metrics (using a custom exporter or node_exporter with --collector.cgroups). Less detailed, but lighter — choose according to your needs.
Zabbix offers a similar agent-based approach: install the Zabbix agent inside the container, add the host in Zabbix, and monitor standard OS metrics. For LXC monitoring from the host side, Zabbix can also use custom items that run lxc-info or read cgroup files.
lxc-info -n c1 -sCombine with alert triggers: "container DOWN", "memory > 90% limit", or "oom_kill > 0" — that's what makes monitoring useful, not just a pretty dashboard.
LXC writes operational logs to /var/log/lxc/:
ls /var/log/lxc/
tail -50 /var/log/lxc/c1.logThese logs contain traces of lxc-start, lxc-stop operations and configuration errors — the first lines to read when a container fails to start.
For systemd containers, service logs inside the container are stored in their own journal. From the host, you can read them directly:
lxc-attach -n c1 -- journalctl -u sshd --no-pager -n 50lxc-attach -n c1 -- journalctl -bThe container boot log (init boot log) can be viewed via the console or lxc-info:
lxc-console -n c1Press Ctrl+A then Q to exit the console back to the host.
Warning
LXC runtime logs (/var/log/lxc/) and container journals are different things: the former is about the LXC operations themselves (start/stop/config), the latter about services inside the container. When a "container fails to start", read /var/log/lxc/c1.log first; when a "service inside the container has a problem", read the container journal.
A reliable minimum pattern:
memory.current passes 90% of memory.max.oom_kill increases.cat /sys/fs/cgroup/lxc/c1/memory.eventsKey takeaways:
lxc-info -n c1 -s and lxc-ls -f are the fastest status checks.systemd-cgtop for a live view.lxc-info./var/log/lxc/ for LXC operations, per-container journal for services, lxc-console for boot logs.In the next episode 21 we'll cover roadmap & community — LXC's development direction (latest kernel, cgroup2, security, LTS 7.0 coordination through 2031) and the community channels: linuxcontainers.org, GitHub lxc/lxc, the discuss.linuxcontainers.org forum, and the #lxc IRC.