Skip to main content

Install Alloy

Config

Edit /etc/alloy/config.alloy:
Defines the log files Alloy should watch. Each entry in path_targets is a file path plus labels (job, app, host, type) that get attached to every log line shipped from that file — these labels are what you filter on later in Grafana/Loki queries.
Tails the files matched above and forwards new log lines to the configured receiver.
Pushes the collected logs to Loki’s push API. The endpoint matches the Loki setup running on port 4100 (http://127.0.0.1:4100/loki/api/v1/push).
Add a new block inside path_targets for every new app you deploy — just point __path__ at its PM2 log file and give it a unique app label.

systemd service

The Alloy package installs a systemd service automatically at /etc/systemd/system/alloy.service. Enable and start it:
If you need to check or edit the service definition:
Only Alloy needs restarting after editing /etc/alloy/config.alloy — Loki and Grafana don’t need to be touched for log-source config changes.

Restart Alloy after config changes

Verify it’s shipping logs