Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Loki to Dev Environment Stack #435

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions server/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@ services:
ports:
- "3000:3000"

# Add Loki service
loki:
image: grafana/loki:2.9.2
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml

# Add Promtail service
promtail:
image: grafana/promtail:2.8.2
container_name: promtail
depends_on:
- loki
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro # Mount Docker socket
- ./promtail-config.yaml:/etc/promtail/config.yaml:ro
command: --config.file=/etc/promtail/config.yaml
34 changes: 34 additions & 0 deletions server/docker/loki-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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
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
10 changes: 10 additions & 0 deletions server/docker/metrics/datasources/datasources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ datasources:
editable: true
jsonData:
timeInterval: 1s

- name: Loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: false
version: 1
editable: true
33 changes: 33 additions & 0 deletions server/docker/promtail-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server:
http_listen_port: 9080
grpc_listen_port: 0
clients:
- url: http://loki:3100/loki/api/v1/push
positions:
filename: /tmp/positions.yaml
scrape_configs:
# Docker Service Discovery
- job_name: docker-logs
docker_sd_configs:
- host: unix:///var/run/docker.sock
pipeline_stages:
- docker:
docker_url: unix:///var/run/docker.sock
# This multiline stage merges multiple lines for one exception stack trace
# into a single log message.
- multiline:
# firstline: A regex that identifies the start of a new log entry
firstline: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
# Maximum wait time for more lines before sending the collected log upstream
max_wait_time: 3s
relabel_configs:
- source_labels: [__meta_docker_container_name]
regex: "/(.*)"
replacement: "$1"
target_label: container_name
- source_labels: [__meta_docker_container_image]
target_label: image
- source_labels: [__meta_docker_container_id]
target_label: container_id
- target_label: job
replacement: docker-logs
Loading