ruanbekker / docker-loki-distributed-minio

Distributed Loki setup with BoltDB and Minio using Docker

Home Page:https://ruan.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-loki-distributed-minio

Distributed Loki setup with BoltDB and Minio using Docker

About

There's options for using different ring backend storage:

  • The docker-compose.yml provides a distributed loki stack with etcd as the backend kvstore
  • The docker-compose-consul.yml provides a distrubuted loki stack with consul as the backend kvstore
  • The docker-compose-traefik.yml provides a distrubuted loki stack with etcd as the backend kvstore

Components

This stack consists of:

  • loki-distributor (promtail or docker logging driver points to this component)
  • loki-querier (grafana or logcli points to this component)
  • loki-ingester
  • loki-table-manager
  • redis
  • etcd or consul

The architecture document can be viewed here

Pre-Requisites

For your containers to use to loki logging driver, you need to install it using:

$ docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions

Logging Options

To use loki logging driver (push logs directly to loki):

    logging:
      driver: loki
      options:
        loki-url: http://localhost:3101/loki/api/v1/push
        loki-external-labels: job=dockerlogs,environment=development

To use json file logging driver (and let promtail scrape the logs):

    logging:
      driver: "json-file"
      options:
        max-size: "1m"
        max-file: "1"
        tag: "{{.Name}}"

Boot the Stack:

I will boot the stack that includes consul as a backend:

docker-compose -f docker-compose-consul.yml up -d --build

Make HTTP Requests

Test the flask-app:

curl 'http://localhost:5000/?msg=hi'

Test the nginx-app:

curl 'http://localhost:8084/?msg=bye'

Example Queries

Query labels as k/v pairs using logfmt:

{container_name="flask-app"} | logfmt |= "scheme=http"

Metric Queries: Log Entries sum by container_name:

sum(rate({job="containerlogs"}[30s])) by (container_name)

Resources

Extra credit goes to the ones in the below issues, as I retrieved most of the loki config from there:

Documentation on Loki:

Extra resources to add a Go app to this stack:

Similar:

About

Distributed Loki setup with BoltDB and Minio using Docker

https://ruan.dev


Languages

Language:Python 39.0%Language:Makefile 34.7%Language:Dockerfile 15.1%Language:Shell 11.1%