Zum Inhalt

Monat: August 2022

Grafana Loki mit Docker

Es ist relativ einfach, Grafana Loki als Logging Stack zu nutzen. Dann lassen sich sehr bequem die Logs aller Container zentral sammeln und einsehen (via Grafana).

Den passenden Treiber für Docker gibt es hier: https://grafana.com/docs/loki/latest/clients/docker-driver/

Nun noch das docker-compose.yml File um Loki zu starten (in diesem Stack könnte z.B. auch direkt Grafana mit dazugepackt werden):

version: '3.3'
services:
  loki:
    container_name: grafana-loki
    image: 'grafana/loki:latest'
    ports:
      - '3100:3100'
    command: '-config.file=/etc/loki/local-config.yaml'
    restart: unless-stopped
    volumes:
      - 'loki-data:/loki'
      - './loki/local-config.yaml:/etc/loki/local-config.yaml'
volumes:
  loki-data: null

Und noch die dazugehörige Loki Config mit einer Retention von 180 Tagen:

auth_enabled: false

server:
  http_listen_port: 3100

common:
  path_prefix: /loki
  storage:
    filesystem:
      chunks_directory: /loki/chunks
      rules_directory: /loki/rules
  replication_factor: 1
  ring:
    instance_addr: 127.0.0.1
    kvstore:
      store: inmemory

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

compactor:
  working_directory: /loki/retention
  shared_store: filesystem
  compaction_interval: 10m
  retention_enabled: true
  retention_delete_delay: 2h
  retention_delete_worker_count: 150

limits_config:
  retention_period: 180d