loki-prune

  • Original
  • Go
  • v1.2.4

Automated storage-quota rotator and streaming compressor for Grafana Loki. Watches configured chunk directories, flushes in-memory streams via Loki's POST /flush API, rotates oldest chunks, and compresses archives with zstd or gzip.

Install

Go / Docker
go install github.com/blackbirdworks/loki-prune/cmd/loki-prune@latest
# or Docker:
docker pull ghcr.io/blackbirdworks/loki-prune:latest

CLI Flags & Modes

Available CLI options and daemon modes
Flag / Mode Behavior
--config <path> Path to the YAML quota and Loki coordination configuration file.
--mode poll Default stateless periodic walk (interval, adaptive backoff, zero inotify watches).
--mode fsevent Real-time recursive fsnotify inventory with configurable write cooldown.
--once Evaluate and rotate once, then exit (ideal for scheduled cron jobs).
--dry-run Report planned rotations, compressions, and prunes without modifying files.

Example Configuration

loki-prune.yaml
loki:
  url: "http://127.0.0.1:3100"
  flush_before_rotate: true
  reload_after_rotate: true

daemon:
  mode: "poll"
  interval: "5m"
  adaptive: true

paths:
  - name: "loki-chunks"
    path: "/data/loki/chunks"
    archive_dir: "/data/loki/archive"
    trigger_size: "48GB"
    target_size: "40GB"
    rotation:
      max_rotations: 10
      compress: true
      type: "zstd"
      level: 3
      delay:
        rotations: 2
        age: "24h"