18 grudnia 2021

Docker #8 - Grafana

Grafana dashbord to tu będziemy wyświetlać logi z Loki oraz dane zebrane z monitorów za pośrednictwem Prometheus.

Konfiguracja

docker composer

version: "3.8"

services:
  grafana:
    user: 0:0
    network_mode: host
    stop_grace_period: 20s
    stop_signal: SIGINT
    container_name: grafana
    restart: unless-stopped
    image: grafana/grafana:latest
    environment: {}
    volumes:
      - /global_config/docker_data/grafana/data:/var/lib/grafana
      - /global_config/docker_data/grafana/log:/var/log/grafana
      - /global_config/composer/grafana/grafana.ini:/etc/grafana/grafana.ini
    labels:
      - traefik.enable=true
      - traefik.http.routers.grafana.rule=Host(`grafana.home.robertolechowski.com`)
      - traefik.http.routers.grafana.tls.certresolver=myresolver
      - traefik.http.routers.grafana.service=grafana_service
      - traefik.http.services.grafana_service.loadbalancer.server.port=3000

Konfiguracja Grafana


app_mode = production # possible values : production, development
instance_name = ${HOSTNAME}

[paths]
data = /var/lib/grafana
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins # Directory where grafana will automatically scan and look for plugins


[server]
protocol = http
http_port = 3000

[database]
type = sqlite3
host = 127.0.0.1:3306
;name = grafana
;user = root
;password =

;ssl_mode = disable

path = grafana.db # For "sqlite3" only, path relative to data_path setting

[security]
admin_user = robert
admin_password = demo

secret_key = 6796555d42e54538dcb8e324a81ce431

login_remember_days = 60
cookie_username = grafana_user
cookie_remember_name = grafana_remember

disable_gravatar = false

[users]
allow_sign_up = false
;allow_org_create = true

;auto_assign_org = true # Set to true to automatically assign new users to the default organization (id 1)

;auto_assign_org_role = Viewer # Default role new users will be automatically assigned (if disabled above is set to true)

;login_hint = email or username # Background text for the user field on the login page

default_theme = dark



[log]
# Either "console", "file", "syslog". Default is console and  file
# Use space to separate multiple modes, e.g. "console file"
mode = console, file

level = warn # Either "trace", "debug", "info", "warn", "error", "critical", default is "info"

[log.console]
level = info

# log line format, valid options are text, console and json
;format = console

[log.file]
level = warn

# log line format, valid options are text, console and json
;format = text


log_rotate = true # This enables automated log rotate(switch of following options), default is true

max_lines = 1000000 # Max line number of single file, default is 1000000

max_size_shift = 28 # Max size shift of single file, default is 28 means 1 << 28, 256MB

daily_rotate = true # Segment log daily, default is true

max_days = 14 # Expired days of log file(delete after max days), default is 7

[log.syslog]
;level =

;format = text # log line format, valid options are text, console and json

# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used.
;network =
;address =

;facility = # Syslog facility. user, daemon and local0 through local7 are valid.

;tag = # Syslog tag. By default, the process' argv[0] is used.