Overview
Grafana Loki is a log aggregation system designed to work with both Prometheus and Grafana. It stores logs with minimal indexing by using only labels. This makes it fast, efficient and scalable. Loki supports multi-tenant setups, log querying via LogQL, and integrates with other 3rd party tools like the Promtail agent, and Docker for log ingestion. It uses HTTP API on port 3100 and can store data in your local filesystems, object stores, or cloud platforms.
Resources
- Loki documentation can be found here: Grafana Loki | Grafana Loki documentation
- Binaries to GitHub page can be found here: https://github.com/grafana/loki
Installation
Update your system
sudo apt updateInstall dependencies (“curl” – to fetch Loki binaries, “unzip” – to inflate the binary)
sudo apt install -y curl unzipDownload Loki binary (latest stable version) Note this binary is for my Raspberry Pi 5 using ARM technology. With “curl” the “-L” will allow “curl” to follow a redirect and not fail. The “-O” say save the file from filename and not a generic name like say “output.html“.
curl -LO https://github.com/grafana/loki/releases/latest/download/loki-linux-arm64.zipUnzip the binary. Afte inflation the zip file will be called “loki-linux-arm64“
unzip loki-linux-arm64.zipMove it to “/usr/local/bin” where 3rd party utilities are usually located. Make it executable globally.
sudo mv loki-linux-arm64 /usr/local/bin/loki
sudo chmod 755 /usr/local/bin/lokiCreate the Loki configuration “YAML” file using your favorite editor
vim loki-config.yamlInsert the below configuration. Note that this is a minimum configuration setup and sets up Loki with local storage and no authentication. We can fix that later on.
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9095
ingester:
lifecycler:
ring:
kvstore:
store: inmemory
replication_factor: 1
address: 127.0.0.1
chunk_idle_period: 1h
max_chunk_age: 1h
schema_config:
configs:
- from: 2025-01-01
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
storage_config:
boltdb_shipper:
active_index_directory: /tmp/loki/index
cache_location: /tmp/loki/cache
filesystem:
directory: /tmp/loki/chunks
limits_config:
allow_structured_metadata: false
table_manager:
retention_deletes_enabled: true
retention_period: 168h # 7 daysStart Loki manually. You should see Loki listening on port 3100. You can now point Grafana to it as a data source. Best to run “loki” under “sudo” as this gives it permission to create and then write to “/var/loki”.
sudo loki -config.file=loki-config.yamlEstablish auto startup on boot. Create a “systemd” service file.
sudo vim /etc/systemd/system/loki.serviceIn the “loki.service” file insert the following text and modify “{path}” configuration.
[Unit]
Description=Grafana Loki Log Aggregator
After=network.target
[Service]
ExecStart=/usr/local/bin/loki -config.file=/{path}/loki-config.yaml
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.targetReload all the services run by systems and enable Loki to automatically start on boot.
sudo systemctl daemon-reload
sudo systemctl enable lokiStart Loki and check its status.
sudo systemctl start loki
sudo systemctl status lokiIf the “loki” status looks good with enabled flags, then you’re good to go. I hope this instruction post helped.