Skip to content

Commit e3e9be9

Browse files
authored
feat: add loki to docker-compose (#639)
1 parent 9e48f58 commit e3e9be9

File tree

6 files changed

+158
-10
lines changed

6 files changed

+158
-10
lines changed

Diff for: .gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,20 @@ priv
4444
.vscode/
4545

4646
# spec-test vectors
47-
test/spec/vectors
47+
/test/spec/vectors
4848

49-
native/libp2p_port/libp2p_port
49+
/native/libp2p_port/libp2p_port
5050

5151
# Proto generated code.
5252
*.pb.ex
5353
*.pb.go
5454

5555
# local db.
56-
level_db
56+
/level_db
57+
/logs
5758

5859
# Generated tests
59-
test/generated
60+
/test/generated
6061

6162
# profiling artifacts
6263
callgrind.out.*

Diff for: config/config.exs

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ import Config
44
# Configure logging
55
config :logger, level: :info, truncate: :infinity
66

7+
## TODO: we might want to enable this with a CLI flag
8+
## Uncomment to log to a file
9+
# config :logger, :default_handler,
10+
# config: [
11+
# file: ~c"logs/system.log",
12+
# filesync_repeat_interval: 5000,
13+
# file_check: 5000,
14+
# max_no_bytes: 10_000_000,
15+
# max_no_files: 5,
16+
# compress_on_rotate: true
17+
# ]
18+
719
# Configures the phoenix endpoint
820
config :lambda_ethereum_consensus, BeaconApi.Endpoint,
921
http: [port: 4000],

Diff for: metrics/docker-compose.yml

+68-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
version: '0.1'
1+
version: '3'
22
name: 'lambda-ethereum-consensus-grafana'
33

44
services:
55
prometheus:
66
image: prom/prometheus
77
container_name: prometheus
88
hostname: prometheus
9-
ports:
10-
- "9090:9090"
119
volumes:
10+
# prometheus configuration
1211
- ./prometheus:/etc/prometheus
12+
# prometheus data
1313
- prometheus-data:/prometheus
1414
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
1515
networks:
16-
open:
16+
grafana-prometheus:
1717
aliases:
1818
- prometheus
1919
extra_hosts:
@@ -25,17 +25,79 @@ services:
2525
ports:
2626
- "3000:3000"
2727
volumes:
28+
# grafana configuration
2829
- ./grafana/provisioning:/etc/grafana/provisioning
30+
# grafana data
2931
- grafana-data:/var/lib/grafana
32+
environment:
33+
# WARNING: use this for same-machine access ONLY
34+
GF_AUTH_ANONYMOUS_ENABLED: "true"
35+
GF_AUTH_DISABLE_LOGIN_FORM: "true"
36+
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
3037
networks:
31-
open:
38+
grafana-prometheus:
39+
aliases:
40+
- grafana
41+
grafana-loki:
3242
aliases:
3343
- grafana
3444

45+
# Since the Loki containers are running as user 10001 and the mounted data volume is owned by root,
46+
# Loki would not have permissions to create the directories.
47+
# Therefore the init container changes permissions of the mounted directory.
48+
loki-init:
49+
image: &lokiImage grafana/loki:2.9.2
50+
user: root
51+
entrypoint:
52+
- "chown"
53+
- "10001:10001"
54+
- "/tmp/loki"
55+
volumes:
56+
- loki-data:/tmp/loki
57+
58+
loki:
59+
image: *lokiImage
60+
container_name: loki
61+
volumes:
62+
# loki configuration
63+
- ./loki:/etc/loki
64+
# loki data
65+
- loki-data:/tmp/loki
66+
command: --config.file=/etc/loki/loki.yml
67+
networks:
68+
grafana-loki:
69+
aliases:
70+
- loki
71+
loki-promtail:
72+
aliases:
73+
- loki
74+
75+
promtail:
76+
image: grafana/promtail
77+
container_name: promtail
78+
volumes:
79+
# promtail configuration
80+
- ./promtail:/etc/promtail
81+
# logs to scrape
82+
- ../logs:/var/log/consensus
83+
# promtail data
84+
- promtail-data:/tmp/promtail
85+
command: --config.file=/etc/promtail/promtail.yml
86+
networks:
87+
loki-promtail:
88+
aliases:
89+
- promtail
90+
3591
networks:
36-
open:
92+
grafana-prometheus:
93+
driver: bridge
94+
grafana-loki:
95+
driver: bridge
96+
loki-promtail:
3797
driver: bridge
3898

3999
volumes:
40100
prometheus-data:
41101
grafana-data:
102+
loki-data:
103+
promtail-data:

Diff for: metrics/grafana/provisioning/datasources/loki_ds.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
datasources:
2+
- name: Loki
3+
access: proxy
4+
type: loki
5+
url: http://loki:3100
6+
isDefault: false

Diff for: metrics/loki/loki.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
auth_enabled: false
2+
3+
server:
4+
http_listen_port: 3100
5+
grpc_listen_port: 9096
6+
7+
common:
8+
instance_addr: 127.0.0.1
9+
path_prefix: /tmp/loki
10+
storage:
11+
filesystem:
12+
chunks_directory: /tmp/loki/chunks
13+
rules_directory: /tmp/loki/rules
14+
replication_factor: 1
15+
ring:
16+
kvstore:
17+
store: inmemory
18+
19+
query_range:
20+
results_cache:
21+
cache:
22+
embedded_cache:
23+
enabled: true
24+
max_size_mb: 100
25+
26+
schema_config:
27+
configs:
28+
- from: 2020-10-24
29+
store: boltdb-shipper
30+
object_store: filesystem
31+
schema: v11
32+
index:
33+
prefix: index_
34+
period: 24h
35+
36+
ruler:
37+
alertmanager_url: http://localhost:9093
38+
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
39+
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
40+
#
41+
# Statistics help us better understand how Loki is used, and they show us performance
42+
# levels for most users. This helps us prioritize features and documentation.
43+
# For more information on what's sent, look at
44+
# https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go
45+
# Refer to the buildReport method to see what goes into a report.
46+
#
47+
# If you would like to disable reporting, uncomment the following lines:
48+
#analytics:
49+
# reporting_enabled: false

Diff for: metrics/promtail/promtail.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server:
2+
http_listen_port: 9080
3+
grpc_listen_port: 0
4+
5+
positions:
6+
filename: /tmp/promtail/positions.yaml
7+
8+
clients:
9+
- url: http://loki:3100/loki/api/v1/push
10+
11+
scrape_configs:
12+
- job_name: system
13+
static_configs:
14+
- targets:
15+
- localhost
16+
labels:
17+
job: lambda_ethereum_consensus
18+
__path__: /var/log/consensus/*log

0 commit comments

Comments
 (0)