Centralized Homelab Logging: Vector, Grafana Loki, and Structured JSON Telemetry

2 min read

Searching through disjointed log files across multiple VPS instances, TrueNAS servers, and Docker containers with journalctl and grep is time-consuming and inefficient during outages.

Modern infrastructure aggregates all system, container, and edge firewall logs into a centralized, searchable telemetry pipeline using Vector (log collector) and Grafana Loki.

⚡ Quick Runbook: 60-Second Implementation

TL;DR: Copy and deploy the baseline production definition directly onto your host:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "20m",
    "max-file": "5"
  }
}

1. The Logging Pipeline Architecture

  1. Docker Daemon & Journald: Applications emit logs to stdout/stderr in JSON format.
  2. Vector Agent: A lightweight Rust-based log shipper running on each host reads Docker sockets and systemd journal, parses timestamps, strips noise, and ships compressed streams.
  3. Grafana Loki: Indexes metadata labels rather than full text, keeping memory footprint low and storage costs fractionally lower than Elasticsearch.

2. Docker Logging Driver Configuration

Configure Docker daemon globally in /etc/docker/daemon.json to enforce log rotation and prevent disk exhaustion:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "20m",
    "max-file": "5"
  }
}

Related Runbooks in This Series

Tags:

← Previous:
Next: →