From 78c9e656cf41c2d450c722bf5b4e32a37f5d54da Mon Sep 17 00:00:00 2001 From: Thomas Daniel Galligan Date: Wed, 10 Nov 2021 10:31:17 +0000 Subject: [PATCH] added logging --- docker-compose.yml | 43 ++++++++++++++++++++++++++++++++- loki/loki.yml | 55 +++++++++++++++++++++++++++++++++++++++++++ promtail/promtail.yml | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 loki/loki.yml create mode 100644 promtail/promtail.yml diff --git a/docker-compose.yml b/docker-compose.yml index d524947..00e7216 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock + postgres-timber: container_name: pgres image: "postgres" @@ -33,6 +34,7 @@ services: "-c", "log_min_error_statement=ERROR", ] + redis-timber: container_name: rdis image: "redis:alpine" @@ -42,6 +44,7 @@ services: - "6379:6379" volumes: - "rdbdata_timber:/data" + timber-api: command: modd container_name: timber-api @@ -78,6 +81,11 @@ services: - postgres-timber - redis-timber - reverse-proxy + logging: + driver: json-file + options: + tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}" + timber-client: container_name: timber-client build: @@ -102,6 +110,39 @@ services: volumes: - ./ui:/app - /app/node_modules + + grafana: + image: grafana/grafana + container_name: grafana + ports: + - "3000:3000" + environment: + GF_SECURITY_ADMIN_PASSWORD: ADMIN1234 + GF_SECURITY_ADMIN_USER: ADMIN + GF_AUTH_ANONYMOUS_ENABLED: false + GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer + GF_AUTH_ANONYMOUS_ORG_NAME: Public + + loki: + image: grafana/loki:2.3.0 + container_name: loki + ports: + - "3100:3100" + command: "--config.file=/etc/loki/loki.yml" + volumes: + - ./loki:/etc/loki + + promtail: + image: grafana/promtail + container_name: promtail + ports: + - "9090:9090" + command: "--config.file=/etc/promtail/promtail.yml" + volumes: + - ./promtail:/etc/promtail + - /var/lib/docker:/var/lib/docker:ro + + volumes: pgdata_timber: - rdbdata_timber: \ No newline at end of file + rdbdata_timber: diff --git a/loki/loki.yml b/loki/loki.yml new file mode 100644 index 0000000..47b70f0 --- /dev/null +++ b/loki/loki.yml @@ -0,0 +1,55 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + log_level: error + +ingester: + lifecycler: + address: 127.0.0.1 + ring: + kvstore: + store: inmemory + replication_factor: 1 + final_sleep: 0s + chunk_idle_period: 5m + chunk_retain_period: 30s + +schema_config: + configs: + - from: 2021-11-09 + store: boltdb + object_store: filesystem + schema: v9 + index: + prefix: index_ + period: 168h + +storage_config: + boltdb: + directory: /tmp/loki/index + + filesystem: + directory: /tmp/loki/chunks + +limits_config: + enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h + +chunk_store_config: + max_look_back_period: 0 + +table_manager: + chunk_tables_provisioning: + inactive_read_throughput: 0 + inactive_write_throughput: 0 + provisioned_read_throughput: 0 + provisioned_write_throughput: 0 + index_tables_provisioning: + inactive_read_throughput: 0 + inactive_write_throughput: 0 + provisioned_read_throughput: 0 + provisioned_write_throughput: 0 + retention_deletes_enabled: false + retention_period: 0 diff --git a/promtail/promtail.yml b/promtail/promtail.yml new file mode 100644 index 0000000..9bfe483 --- /dev/null +++ b/promtail/promtail.yml @@ -0,0 +1,43 @@ +server: + http_listen_address: 0.0.0.0 + http_listen_port: 9080 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://loki:3100/loki/api/v1/push + +scrape_configs: + - job_name: docker + static_configs: + - targets: + - localhost + labels: + job: dockerlogs + __path__: /var/lib/docker/containers/*/*log + pipeline_stages: + - json: + expressions: + output: log + stream: stream + attrs: + - json: + expressions: + tag: + source: attrs + - regex: + expression: (?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])) + source: tag + - timestamp: + format: RFC3339Nano + source: time + - labels: + tag: + stream: + image_name: + container_name: + image_id: + container_id: + - output: + source: output \ No newline at end of file