Skip to content

Commit

Permalink
Add loki log-monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Oct 20, 2024
1 parent e1e0f8e commit c23c191
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 9 deletions.
28 changes: 20 additions & 8 deletions monitoring/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
prometheus:
condition: service_healthy
networks:
- monitoring
- default
- webserver

node-exporter:
Expand All @@ -55,8 +55,6 @@ services:
depends_on:
prometheus:
condition: service_healthy
networks:
- monitoring

prometheus:
image: prom/prometheus
Expand All @@ -68,8 +66,6 @@ services:
interval: 10s
timeout: 3s
retries: 3
networks:
- monitoring

watchtower:
image: containrrr/watchtower
Expand All @@ -83,8 +79,6 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- /config.json:/config.json:ro
command: --interval 60 --cleanup --rolling-restart
networks:
- monitoring

autoheal:
image: willfarrell/autoheal
Expand All @@ -95,11 +89,29 @@ services:
environment:
AUTOHEAL_CONTAINER_LABEL: all

loki:
image: grafana/loki
restart: always
command: -config.file=/etc/loki/loki.yaml
volumes:
- ./loki.yaml:/etc/loki/loki.yaml

promtail:
image: grafana/promtail
restart: always
volumes:
- ./promtail.yaml:/etc/promtail/docker-config.yaml
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock
command: -config.file=/etc/promtail/docker-config.yaml
depends_on:
- loki

volumes:
grafana-data:

networks:
monitoring:
default:
name: monitoring
webserver:
external: true
7 changes: 6 additions & 1 deletion monitoring/grafana/datasource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ datasources:
uid: main-prometheus
isDefault: true
access: proxy
editable: true
editable: false
- name: Loki
type: loki
url: http://loki:3100
uid: main-loki
editable: false
52 changes: 52 additions & 0 deletions monitoring/loki.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
auth_enabled: false

server:
http_listen_port: 3100
grpc_listen_port: 9096

common:
instance_addr: 127.0.0.1
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory

frontend:
max_outstanding_per_tenant: 2048

pattern_ingester:
enabled: true

limits_config:
max_global_streams_per_user: 0
ingestion_rate_mb: 50000
ingestion_burst_size_mb: 50000
volume_enabled: true

query_range:
results_cache:
cache:
embedded_cache:
enabled: true
max_size_mb: 100

schema_config:
configs:
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h

ruler:
alertmanager_url: http://localhost:9093

analytics:
reporting_enabled: false
18 changes: 18 additions & 0 deletions monitoring/promtail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server:
http_listen_port: 9080
grpc_listen_port: 0

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: docker_logs
__path__: /var/lib/docker/containers/*/*-json.log

0 comments on commit c23c191

Please sign in to comment.