Skip to content

Instantly share code, notes, and snippets.

@kalaspuffar
Last active April 29, 2023 16:05
Show Gist options
  • Save kalaspuffar/4143e7764c322711eef26ac40cd20b75 to your computer and use it in GitHub Desktop.
Save kalaspuffar/4143e7764c322711eef26ac40cd20b75 to your computer and use it in GitHub Desktop.
loki_promtail.md

======================== 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 [email protected]:.
scp loki.service [email protected]:.
scp promtail.yaml [email protected]:.
scp promtail.service [email protected]:.
scp promtail.yaml [email protected]:.
scp promtail.service [email protected]:.
scp promtail.yaml [email protected]:.
scp promtail.service [email protected]:.
scp promtail.yaml [email protected]:.
scp promtail.service [email protected]:.
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 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment