Skip to content

Commit 2f772c2

Browse files
authored
chore: added loki logs to example docker-compose (#385)
1 parent eb43206 commit 2f772c2

File tree

5 files changed

+203
-11
lines changed

5 files changed

+203
-11
lines changed

example/docker-compose.yml

+93-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
# Copyright 2020 ChainSafe Systems
22
# SPDX-License-Identifier: LGPL-3.0-only
33

4+
x-logging:
5+
&default-logging
6+
driver: "json-file"
7+
options:
8+
max-size: "1m"
9+
max-file: "1"
10+
tag: "{{.Name}}"
11+
412
services:
513
mempool-stub:
614
image: ghcr.io/sygmaprotocol/beacon-api-stub
15+
container_name: mempool-stub
16+
labels:
17+
logging: "promtail"
18+
logging_jobname: "containerlogs"
719
volumes:
820
- "./cfg/stubs:/stubs"
921
ports:
1022
- 8882:8882
1123
environment:
1224
- STUB_DATA=/stubs/mempool.yml
25+
logging: *default-logging
1326

1427
bitcoin:
1528
# image: ruimarinho/bitcoin-core:latest
1629
image: ghcr.io/sygmaprotocol/bitcoin
1730
container_name: bitcoin
31+
labels:
32+
logging: "promtail"
33+
logging_jobname: "containerlogs"
1834
ports:
1935
- "18443:18443"
2036
- "18332:18332"
@@ -27,40 +43,52 @@ services:
2743
volumes:
2844
- ./cfg/entrypoint/entrypoint.sh:/cfg/entrypoint/entrypoint.sh
2945
entrypoint: /cfg/entrypoint/entrypoint.sh
46+
logging: *default-logging
3047

3148
evm1-1:
3249
image: ghcr.io/sygmaprotocol/sygma-solidity:evm1-v2.10.1
3350
container_name: evm1-1
3451
command: --chain.chainId 1337 --db data/ --blockTime 2 --m 'black toward wish jar twin produce remember fluid always confirm bacon slush' > /dev/null
35-
logging:
36-
driver: none
52+
labels:
53+
logging: "promtail"
54+
logging_jobname: "containerlogs"
55+
logging: *default-logging
3756
ports:
3857
- "8545:8545"
3958

4059
evm2-1:
4160
image: ghcr.io/sygmaprotocol/sygma-solidity:evm2-v2.10.1
4261
command: --chain.chainId 1338 --db data/ --blockTime 2 --m 'black toward wish jar twin produce remember fluid always confirm bacon slush' > /dev/null
4362
container_name: evm2-1
44-
logging:
45-
driver: none
63+
labels:
64+
logging: "promtail"
65+
logging_jobname: "containerlogs"
66+
logging: *default-logging
4667
ports:
4768
- "8547:8545"
4869

4970
substrate-pallet:
50-
container_name: substrate-pallet
5171
image: "ghcr.io/sygmaprotocol/sygma-substrate-pallets:e2e-v0.3.1"
72+
container_name: substrate-pallet
73+
labels:
74+
logging: "promtail"
75+
logging_jobname: "containerlogs"
5276
ports:
5377
- "9944:9944"
5478
- "9933:9933"
55-
79+
logging: *default-logging
80+
5681
ipfs0:
57-
container_name: ipfs0
5882
image: ipfs/kubo:release
83+
container_name: ipfs0
84+
labels:
85+
logging: "promtail"
86+
logging_jobname: "containerlogs"
5987
ports:
60-
- "4001:4001"
61-
- "5002:5001"
62-
- "8080:8080"
63-
88+
- "4001:4001"
89+
- "5002:5001"
90+
- "8080:8080"
91+
logging: *default-logging
6492

6593
relayer1:
6694
container_name: example_relayer1
@@ -71,9 +99,13 @@ services:
7199
depends_on:
72100
- evm1-1
73101
- substrate-pallet
102+
labels:
103+
logging: "promtail"
104+
logging_jobname: "containerlogs"
74105
volumes:
75106
- ./cfg:/cfg
76107
restart: always
108+
logging: *default-logging
77109

78110
relayer2:
79111
container_name: example_relayer2
@@ -84,9 +116,13 @@ services:
84116
depends_on:
85117
- evm1-1
86118
- substrate-pallet
119+
labels:
120+
logging: "promtail"
121+
logging_jobname: "containerlogs"
87122
volumes:
88123
- ./cfg:/cfg
89124
restart: always
125+
logging: *default-logging
90126

91127
relayer3:
92128
container_name: example_relayer3
@@ -97,15 +133,61 @@ services:
97133
depends_on:
98134
- evm1-1
99135
- substrate-pallet
136+
labels:
137+
logging: "promtail"
138+
logging_jobname: "containerlogs"
100139
volumes:
101140
- ./cfg:/cfg
102141
restart: always
142+
logging: *default-logging
103143

104144
otel-collector:
105145
container_name: otel-collector
106146
image: otel/opentelemetry-collector
107147
command: ["--config=/etc/otel-collector-config.yml"]
148+
labels:
149+
logging: "promtail"
150+
logging_jobname: "containerlogs"
108151
volumes:
109152
- ./cfg/otel-collector-config.yml:/etc/otel-collector-config.yml
110153
ports:
111154
- "8889:8889" # Prometheus exporter metrics
155+
logging: *default-logging
156+
157+
grafana:
158+
image: grafana/grafana:11.3.0
159+
container_name: grafana
160+
ports:
161+
- 3000:3000
162+
volumes:
163+
- ./grafana/datasources/grafana.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
164+
- ./grafana/plugins/app.yaml:/etc/grafana/provisioning/plugins/app.yaml
165+
environment:
166+
- GF_AUTH_ANONYMOUS_ENABLED=true
167+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
168+
- GF_AUTH_DISABLE_LOGIN_FORM=true
169+
- GF_FEATURE_TOGGLES_ENABLE=accessControlOnCall lokiLogsDataplane
170+
- GF_INSTALL_PLUGINS=grafana-lokiexplore-app
171+
logging: *default-logging
172+
173+
loki:
174+
image: grafana/loki:3.0.0
175+
container_name: loki
176+
ports:
177+
- 3100:3100
178+
command: -config.file=/etc/loki/loki.yaml
179+
volumes:
180+
- ./loki/loki.yaml:/etc/loki/loki.yaml
181+
logging: *default-logging
182+
183+
promtail:
184+
image: grafana/promtail:3.0.0
185+
container_name: promtail
186+
volumes:
187+
- ./promtail/promtail.yaml:/etc/promtail/docker-config.yaml
188+
- /var/lib/docker/containers:/var/lib/docker/containers:ro
189+
- /var/run/docker.sock:/var/run/docker.sock
190+
command: -config.file=/etc/promtail/docker-config.yaml
191+
depends_on:
192+
- loki
193+
logging: *default-logging
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Loki
5+
type: loki
6+
access: proxy
7+
url: http://loki:3100
8+
version: 1
9+
editable: false
10+
isDefault: true

example/grafana/plugins/app.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: 1
2+
3+
apps:
4+
- type: "grafana-lokiexplore-app"
5+
org_id: 1
6+
org_name: "Grafana"
7+
disabled: false
8+
jsonData:
9+
apiUrl: http://localhost
10+
isApiKeySet: true
11+
secureJsonData:
12+
apiKey: example-key

example/loki/loki.yaml

+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+
frontend:
20+
max_outstanding_per_tenant: 2048
21+
22+
pattern_ingester:
23+
enabled: true
24+
25+
limits_config:
26+
max_global_streams_per_user: 0
27+
ingestion_rate_mb: 50000
28+
ingestion_burst_size_mb: 50000
29+
volume_enabled: true
30+
31+
query_range:
32+
results_cache:
33+
cache:
34+
embedded_cache:
35+
enabled: true
36+
max_size_mb: 100
37+
38+
schema_config:
39+
configs:
40+
- from: 2020-10-24
41+
store: tsdb
42+
object_store: filesystem
43+
schema: v13
44+
index:
45+
prefix: index_
46+
period: 24h
47+
48+
analytics:
49+
reporting_enabled: false

example/promtail/promtail.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# https://grafana.com/docs/loki/latest/clients/promtail/configuration/
2+
# https://docs.docker.com/engine/api/v1.41/#operation/ContainerList
3+
server:
4+
http_listen_port: 9080
5+
grpc_listen_port: 0
6+
7+
positions:
8+
filename: /tmp/positions.yaml
9+
10+
clients:
11+
- url: http://loki:3100/loki/api/v1/push
12+
13+
scrape_configs:
14+
- job_name: flog_scrape
15+
docker_sd_configs:
16+
- host: unix:///var/run/docker.sock
17+
refresh_interval: 5s
18+
filters:
19+
- name: label
20+
values: ["logging=promtail"]
21+
relabel_configs:
22+
- source_labels: ['__meta_docker_container_name']
23+
regex: '/(.*)'
24+
target_label: 'container'
25+
- source_labels: ['__meta_docker_container_log_stream']
26+
target_label: 'logstream'
27+
- source_labels: ['__meta_docker_container_label_logging_jobname']
28+
target_label: 'job'
29+
pipeline_stages:
30+
- cri: {}
31+
- multiline:
32+
firstline: ^\d{4}-\d{2}-\d{2} \d{1,2}:\d{2}:\d{2},\d{3}
33+
max_wait_time: 3s
34+
# https://grafana.com/docs/loki/latest/clients/promtail/stages/json/
35+
- json:
36+
expressions:
37+
#message: message
38+
level: level
39+
#output: 'message'

0 commit comments

Comments
 (0)