Configuring Promtail to Collect Systemd Journal Logs
Capture Every Log on Your Ubuntu Server
Modern Ubuntu systems use the `systemd` journal as the central place for all system and service logs. To capture this crucial data, the ‘Ubuntu System Administration Guide’ shows how to create a custom configuration file for Promtail to scrape logs directly from the journal.
The `scrape_configs` section
You’ll create a `config.yml` file for Promtail and add a specific job for the journal:
- job_name: journal
journal:
path: /var/log/journal
labels:
job: systemd-journal
You then mount this configuration file and the host’s `/var/log` directory into the Promtail container. This configuration tells Promtail to tap into the journal and forward all its entries to Loki, ensuring you have a complete and centralized record of everything happening on your server.
This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13