This post documents the setup of a basic log observability stack using Grafana, Loki, and Alloy on Debian or Raspberry Pi OS.
In this example we’re going to ingest logs from a local script that grabs remote data from the National Energy Market (NEM) from SCADA sources and push them to Loki using Alloy, and visualise them in Grafana. This setup can be used for lab or production environments where telemetry pipelines are used.
We’ll cover installation, configuration, and basic verification. No frills—just a clean, working pipeline you can narrate, extend, and troubleshoot.
Check prerequisites
- Installed Grafana – https://www.kyriakou.dev/grafana-installation/
- Installed Loki – https://www.kyriakou.dev/grafana-loki-installation/
- Installed Alloy – https://www.kyriakou.dev/grafana-alloy-installation/
Create Alloy Config to Push Logs to Loki
Create a config file
vim ~/alloy.config.hclAdd the below configurations. Modify the {path} to where the logs are
loki.write "local" {
endpoint {
url = "http://localhost:3100/loki/api/v1/push"
}
}
local.file_match "scada_log" {
path_targets = [
{
path = "/Projects/NEM/Dispatch_SCADA/dispatch_scada_loader.log",
labels = {
job = "scada_loader",
},
},
]
}
loki.source.file "scada_source" {
targets = local.file_match.scada_log.targets
forward_to = [loki.write.local.receiver]
}Run Alloy
Adjust your path accordingly. Note. This is good to testing “alloy” and the “alloy.config.hcl” config file but wont survive a reboot.
sudo alloy run ./alloy.config.hclCreate a service file
sudo vim /etc/systemd/system/alloy.serviceEnter the below text into the service file and adjust the paths for the file locations.
[Unit]
Description=Alloy Telemetry Agent
After=network.target
[Service]
ExecStart=/usr/bin/alloy run /home/bill/alloy.config.hcl
WorkingDirectory=/home/bill
User=root
Restart=always
RestartSec=5
Environment=PATH=/usr/local/bin:/usr/bin:/bin
[Install]
WantedBy=multi-user.target
Reload systemd and enable the service
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable alloysudo systemctl daemon-reexec= Re-executes the systemd process itselfsudo systemctl daemon-reload= Reloads systemd’s unit filessudo systemctl enable alloy= Enables the Alloy service to start automatically at boot
Start Alloy
sudo systemctl start alloy
sudo systemctl status alloysudo systemctl start alloy= Start the Alloy servicesudo systemctl status alloy= Shows the current status of the Alloy service
Check status logs
Use the “journalctl” utility for real-time stream of Alloys “systemd” logs. Similar to a “tail -f log“.
journalctl -u alloy -fCheck the log file user permissions if you’re not seeing much activity. That pretty much concludes this guide. Hope it helps!!