Skip to main content

Loki

Loki serves as the core log aggregation system responsible for storing and indexing logs received by Promtail.

Download & Installation

To get started, begin by downloading the most recent release. Make sure to download the file loki-linux-amd64.zip Once the download is complete, proceed to unzip the file, and you'll be all set to proceed.

mkdir loki
cd loki
wget https://github.com/grafana/loki/releases/download/vX.X.X/loki-linux-amd64.zip
unzip loki-linux-amd64.zip
sudo rm -f loki-linux-amd64.zip
mv loki-linux-amd64.zip loki

Add a symbolic link to the /usr/local/bin/ directory for system-wide access to Loki:

sudo ln -s /home/${USER}/loki/loki /usr/local/bin/

Create a Config file

Inside your loki directory create the config.yaml file:

sudo nano config.yml

Follow the official Loki configuration documentation available here to fill in the config.yaml file. The documentation provides comprehensive guidance on configuring Loki based on your specific requirements. Ensure to review and incorporate the recommended settings to tailor Loki to your desired log aggregation setup.

Add a system unit file

Open the .service with a text editor

sudo nano /etc/systemd/system/loki.service

Paste the below text

loki.service

/etc/systemd/system/loki.service
[Unit]
Description=Loki
After=network-online.target

[Service]
User=<your_user>
TimeoutStartSec=0
CPUWeight=95
IOWeight=95
ExecStart=loki -config.file /home/sentinel/loki/config.yaml
Restart=always
RestartSec=2
LimitNOFILE=800000
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

Reload the systemd Daemon

sudo systemctl daemon-reload

Enable autostart of Loki service

sudo systemctl enable loki.service

Start Loki service

sudo systemctl start loki.service

Use this command to check logs in real time

sudo journalctl -u loki.service -f --output cat

After installing and running Loki, you can verify whether logs are being sent to Loki.

Open Firewall Port

Important

After successfully installing and launching Loki, the next step is to open port 3100. This port should be accessible exclusively from your Validator machine. This action is essential to enable Loki to collect data from Promtail.

sudo ufw allow from validator_ip to monitor_ip port 3100