Skip to content

Commit f0d43d2

Browse files
apham0001aly-obol
andauthored
add promtail (#321)
Co-authored-by: Aly <16789036+aly-obol@users.noreply.github.com>
1 parent 8da55c2 commit f0d43d2

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

.env.sample.mainnet

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@ MEVBOOST_RELAYS=https://0xa15b52576bcbf1072f4a011c0f99f9fb6c66f3e1ff321f11f461d1
140140
# Grafana Loki docker container image version, e.g. `latest` or `2.8.2`.
141141
# See available tags https://hub.docker.com/r/grafana/loki/tags.
142142
#LOKI_VERSION=
143+
144+
# Uncomment these if you have log exporting with Promtail
145+
# and want to disable log export on a particular container.
146+
147+
# NETHERMIND_PROMTAIL_MONITORED=false
148+
# LIGHTHOUSE_PROMTAIL_MONITORED=false
149+
# CHARON_PROMTAIL_MONITORED=false
150+
# LODESTAR_PROMTAIL_MONITORED=false
151+
# MEV_BOOST_PROMTAIL_MONITORED=false
152+
# EJECTOR_PROMTAIL_MONITORED=false
153+
# DV_EXIT_PROMTAIL_MONITORED=false

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
- ${NETHERMIND_PORT_P2P:-30303}:30303/udp # P2P UDP
1717
- ${NETHERMIND_IP_HTTP:-127.0.0.1}:${NETHERMIND_PORT_HTTP:-8545}:8545 # JSON-RPC
1818
- ${NETHERMIND_IP_ENGINE:-127.0.0.1}:${NETHERMIND_PORT_ENGINE:-8551}:8551 # ENGINE-API
19+
labels:
20+
- "promtail-monitored=${NETHERMIND_PROMTAIL_MONITORED:-true}"
1921
command: |
2022
--config=${NETWORK}
2123
--datadir=data
@@ -48,6 +50,8 @@ services:
4850
ports:
4951
- ${LIGHTHOUSE_PORT_P2P:-9000}:9000/tcp # P2P TCP
5052
- ${LIGHTHOUSE_PORT_P2P:-9000}:9000/udp # P2P UDP
53+
labels:
54+
- "promtail-monitored=${LIGHTHOUSE_PROMTAIL_MONITORED:-true}"
5155
command: |
5256
lighthouse bn
5357
--network=${NETWORK}
@@ -97,6 +101,8 @@ services:
97101
- CHARON_NICKNAME=${CHARON_NICKNAME:-}
98102
ports:
99103
- ${CHARON_PORT_P2P_TCP:-3610}:${CHARON_PORT_P2P_TCP:-3610}/tcp # P2P TCP libp2p
104+
labels:
105+
- "promtail-monitored=${CHARON_PROMTAIL_MONITORED:-true}"
100106
networks: [dvnode]
101107
volumes:
102108
- .charon:/opt/charon/.charon
@@ -120,6 +126,8 @@ services:
120126
NETWORK: ${NETWORK}
121127
BUILDER_API_ENABLED: ${BUILDER_API_ENABLED:-false}
122128
BUILDER_SELECTION: ${BUILDER_SELECTION:-builderalways}
129+
labels:
130+
- "promtail-monitored=${LODESTAR_PROMTAIL_MONITORED:-true}"
123131
volumes:
124132
- ./lodestar/run.sh:/opt/lodestar/run.sh
125133
- .charon/validator_keys:/home/charon/validator_keys
@@ -139,6 +147,8 @@ services:
139147
-addr=0.0.0.0:18550
140148
-relay-check
141149
-relays=${MEVBOOST_RELAYS}
150+
labels:
151+
- "promtail-monitored=${MEV_BOOST_PROMTAIL_MONITORED:-true}"
142152
networks: [dvnode]
143153
restart: unless-stopped
144154

logging.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
3+
promtail:
4+
image: grafana/promtail:${PROMTAIL_VERSION:-2.8.2}
5+
environment:
6+
CHARON_LOKI_ADDRESSES: ${CHARON_LOKI_ADDRESSES}
7+
CLUSTER_NAME: ${CLUSTER_NAME}
8+
CLUSTER_PEER: ${CLUSTER_PEER}
9+
command: -config.file=/etc/promtail/config.yml
10+
volumes:
11+
- ./promtail:/etc/promtail
12+
- /var/run/docker.sock:/var/run/docker.sock
13+
networks: [dvnode]
14+
entrypoint: /etc/promtail/run.sh
15+
restart: unless-stopped
16+
17+
networks:
18+
dvnode:

promtail/config.yml.example

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
server:
2+
http_listen_port: 9080
3+
grpc_listen_port: 0
4+
5+
positions:
6+
filename: /tmp/positions.yaml
7+
8+
clients:
9+
- url: $CHARON_LOKI_ADDRESSES
10+
11+
scrape_configs:
12+
- job_name: docker
13+
docker_sd_configs:
14+
- host: unix:///var/run/docker.sock
15+
relabel_configs:
16+
- source_labels:
17+
[__meta_docker_container_label_promtail_monitored]
18+
regex: "true"
19+
action: keep
20+
- source_labels: ['__meta_docker_container_name']
21+
regex: '/(.*)'
22+
replacement: '$1'
23+
target_label: 'container'
24+
- source_labels: ['container']
25+
regex: '.*charon.*'
26+
replacement: 'charon'
27+
target_label: 'job'
28+
- source_labels: ['container']
29+
regex: '.*nethermind.*'
30+
replacement: 'nethermind'
31+
target_label: 'job'
32+
- source_labels: ['container']
33+
regex: '.*lodestar.*'
34+
replacement: 'lodestar'
35+
target_label: 'job'
36+
- source_labels: ['container']
37+
regex: '.*lighthouse.*'
38+
replacement: 'lighthouse'
39+
target_label: 'job'
40+
- target_label: 'cluster_name'
41+
replacement: $CLUSTER_NAME
42+
- target_label: 'cluster_peer'
43+
replacement: $CLUSTER_PEER
44+
pipeline_stages:
45+
- docker: {}

promtail/run.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
if [ -z "$CHARON_LOKI_ADDRESSES" ]; then
4+
echo "Error: \$CHARON_LOKI_ADDRESSES variable is empty" >&2
5+
exit 1
6+
fi
7+
8+
if [ -z "$CLUSTER_NAME" ]; then
9+
echo "Error: \$CLUSTER_NAME variable is empty" >&2
10+
exit 1
11+
fi
12+
13+
if [ -z "$CLUSTER_PEER" ]; then
14+
echo "Error: \$CLUSTER_PEER variable is empty" >&2
15+
exit 1
16+
fi
17+
18+
# Process the template file once
19+
sed -e "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \
20+
-e "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
21+
-e "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
22+
/etc/promtail/config.yml.example > /etc/promtail/config.yml
23+
24+
# Start Promtail with the generated config
25+
/usr/bin/promtail \
26+
-config.file=/etc/promtail/config.yml

0 commit comments

Comments
 (0)