Installing Promtail and Loki for Log Monitoring in Ceph
In this video, we'll show you how to install Promtail and Loki, two open-source log monitoring tools, to gather and monitor your logs in Ceph. We'll also walk you through the steps of making some minor code changes to display the Grafana Explore window, allowing you to monitor your logs directly in the Ceph dashboard.
======================== promtail.yaml ==========================
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://192.168.6.36:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: cephlogs
__path__: /var/log/ceph/*log
========================== loki.yaml ============================
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
common:
instance_addr: 192.168.6.36
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
query_range:
results_cache:
cache:
embedded_cache:
enabled: true
max_size_mb: 100
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
ruler:
alertmanager_url: http://localhost:9093
====================== promtail.service =========================
[Unit]
Description=Loki service used to gather logs.
[Service]
Restart=on-failure
User=root
ExecStart=/usr/local/bin/loki-linux-amd64 -config.file /etc/grafana/loki.yaml
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
scp loki.yaml woden@192.168.6.36:.
scp loki.service woden@192.168.6.36:.
scp promtail.yaml woden@192.168.6.36:.
scp promtail.service woden@192.168.6.36:.
scp promtail.yaml woden@192.168.6.32:.
scp promtail.service woden@192.168.6.32:.
scp promtail.yaml woden@192.168.6.34:.
scp promtail.service woden@192.168.6.34:.
scp promtail.yaml woden@192.168.6.35:.
scp promtail.service woden@192.168.6.35:.
wget https://github.com/grafana/loki/releases/download/v2.8.1/loki-linux-amd64.zip
wget https://github.com/grafana/loki/releases/download/v2.8.1/promtail-linux-amd64.zip
unzip loki-linux-amd64.zip
unzip promtail-linux-amd64.zip
sudo mkdir /etc/grafana
sudo cp loki.yaml /etc/grafana/
sudo cp promtail.yaml /etc/grafana/
sudo cp promtail-linux-amd64 /usr/local/bin/
sudo cp loki-linux-amd64 /usr/local/bin/
sudo cp loki.service /etc/systemd/system
sudo cp promtail.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl start promtail.service
sudo systemctl enable promtail.service
sudo systemctl status promtail.service
sudo systemctl start loki.service
sudo systemctl enable loki.service
sudo systemctl status loki.service
wget https://github.com/grafana/loki/releases/download/v2.8.1/promtail-linux-amd64.zip
unzip promtail-linux-amd64.zip
sudo mkdir /etc/grafana
sudo cp promtail-linux-amd64 /usr/local/bin/
sudo cp promtail.yaml /etc/grafana/
sudo cp promtail.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl start promtail.service
sudo systemctl enable promtail.service
sudo systemctl status promtail.service