systemctl.
High-level workflow:
- Download and extract Alertmanager.
- Create a dedicated
alertmanagersystem user. - Create configuration and storage directories and place the config.
- Install binaries and set correct permissions.
- Create a systemd unit file, reload systemd, and enable/start the service.
This lesson uses Alertmanager v0.24.0 as an example. Replace the version in the commands if you need a newer/older release. For releases see the Alertmanager GitHub releases: https://github.com/prometheus/alertmanager/releases
1. Download and extract Alertmanager
Example (v0.24.0):2. Create a dedicated system user
Create a non-login system user to run Alertmanager:--system is recommended for service accounts; it keeps user IDs in the system range.
3. Create configuration and storage directories
Create the config and storage directories, copy the shipped config into place, and set ownership to thealertmanager user:
Be careful with
chown -R — do NOT run sudo chown -R alertmanager:alertmanager /etc/ or similarly broad commands. Target only /etc/alertmanager (and other specific directories) to avoid damaging system ownerships.4. Install the binaries
Copy thealertmanager binary and the amtool helper to a directory on PATH, set execute permissions, and set ownership:
- Keeping the binaries owned by
rootand world-executable is common and safe; the process will run as thealertmanageruser when started by systemd. - If you prefer, you can set ownership to
alertmanager:alertmanager, butroot:rootis typical.
5. Create the systemd service unit
Create/etc/systemd/system/alertmanager.service with the following content:
--config.filepoints to your Alertmanager config (/etc/alertmanager/alertmanager.yml).--storage.pathsets the data directory (/var/lib/alertmanager).- The unit runs the process as
alertmanager:alertmanager.
6. Start, enable, and verify the service
Start and enable the service so it runs on boot:- Validate that
/etc/alertmanager/alertmanager.ymlis valid YAML (use a linter oramtool check-configif available). - Confirm ownership and permissions: the
alertmanageruser must be able to read the config and write to/var/lib/alertmanager. - Inspect
journalctloutput for startup errors and missing flags or permission issues.
Reference: Example final systemd unit
For convenience, here is the final unit again:- Alertmanager releases: https://github.com/prometheus/alertmanager/releases
- Alertmanager documentation: https://prometheus.io/docs/alerting/latest/alertmanager/
- systemd documentation: https://www.freedesktop.org/wiki/Software/systemd/