Grafana Loki

From NixNet
Revision as of 21:06, 16 September 2021 by Amolith (talk | contribs) (Amolith moved page Loki to Grafana Loki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This article is part of a series of guides that describe NixNet's setup in excruciating detail. If you would like to follow them, please start at the Infrastructure page.
Caution: this guide is not finished yet; following it may leave you with an unuseable machine. To be notified of updates, please create an account and add it to your watchlist.

Installation

We can follow the latest binary install instructions from their github releases. Download the Loki and Promtail binaries.

curl -O -L "https://github.com/grafana/loki/releases/download/v2.2.0/loki-linux-amd64.zip"
curl -O -L "https://github.com/grafana/loki/releases/download/v2.2.0/promtail-linux-amd64.zip"
unzip "loki-linux-amd64.zip"
unzip "promtail-linux-amd64.zip"
# make sure it is executable
chmod a+x "loki-linux-amd64"
chmod a+x "promtail-linux-amd64"

Configure

Grab the sample configurations for Loki and Promtail:

wget https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml
wget https://raw.githubusercontent.com/grafana/loki/master/clients/cmd/promtail/promtail-local-config.yaml

The default Loki config should be good, Loki will just have to be started and pointed to the config. This can be done with a systemd service:

[Unit]
Description=Loki, a log aggregation tool
After=network.target network-online.target
Requires=network-online.target

[Service]
User=loki
Group=loki
ExecStart=/home/loki/loki-linux-amd64 --config.file=/home/loki/loki-local-config.yaml
WorkingDirectory=/home/loki
TimeoutStopSec=5s

[Install]
WantedBy=multi-user.target