Skip to main content
This guide shows how to install and configure the Grafana Alloy agent on Node 2 so it tails local log files and forwards them to a Loki instance on Node 1 (node01:3100). Follow the steps below in order: connect to Node 2, install prerequisites and Alloy, create the Alloy configuration that discovers and tails /var/log/*.log, and verify logs in Grafana Explore (Loki).

1. SSH into Node 2

Start by SSHing into Node 2:

2. Prerequisites and adding Grafana’s apt repository (Debian/Ubuntu)

Install basic utilities (GPG + wget), add the Grafana keyring, and register the apt repository:

Sample installation output (trimmed)

3. Inspect the default Alloy sample config

The package ships a sample config at /etc/alloy/config.alloy. A trimmed excerpt looks like:

4. Configure Alloy to tail /var/log/*.log and forward to Loki

We will add three blocks to the Alloy config:
  • local.file_match — discover files under /var/log/*.log
  • loki.source.file — create a file source that tails those files
  • loki.write — forward scraped logs to the Loki endpoint
Create or replace /etc/alloy/config.alloy with the following content. This example tails files under /var/log/*.log and forwards them to the Loki instance at http://node01:3100/loki/api/v1/push:
Note: tail_from_end = true prevents Alloy from ingesting the entire previous file history; it starts tailing new lines from the end of each file.
If you need to filter noisy log lines before sending to Loki, insert a processing stage (for example, loki.process "filter_logs" using stage.drop) and forward from loki.source.file to loki.process.filter_logs.receiver instead of directly to the write receiver.
Ensure network connectivity and access control: Alloy must be able to reach node01:3100. If Loki is protected, configure basic_auth or other auth methods in loki.write. Also verify any firewall rules between Node 2 and Node 1 allow port 3100.

5. Reload/Restart Alloy and check status

After saving /etc/alloy/config.alloy, reload the systemd units and restart Alloy:
Verify the files present on the node (example):
Once Alloy is running with the updated configuration, it will discover files matching /var/log/*.log, tail new lines, and push them to the configured Loki endpoint on node01.

6. Verify logs in Grafana Explore (Loki)

Open Grafana and go to Explore → Loki to query logs. Example LogQL to select logs from /var/log/dpkg.log:
Refresh the Explore view and click Run. You should see streaming log lines from Node 2 for matched files.
A dark-themed Grafana Explore screen showing the Loki log query builder with label filters and a "Select value" field, plus a left sidebar of navigation items. The query area shows "No data" in the results panel.
If no logs appear, check Alloy’s journal logs and network reachability from Node 2 to Node 1.

Troubleshooting checklist

  • Verify Alloy service is active:
    • sudo systemctl status alloy
  • Inspect Alloy logs live:
    • sudo journalctl -u alloy -f
  • Confirm Loki is reachable from Node 2:
    • curl -sS http://node01:3100/ready
    • curl -sS http://node01:3100/loki/api/v1/labels --fail
  • If Loki requires authentication, configure it in loki.write and ensure credentials are correct.
  • If no labels appear, confirm local.file_match path patterns match existing files and that tail_from_end behavior is understood (it won’t send historical lines).

Quick Reference

Watch Video