Skip to content

Commit 47123ef

Browse files
committed
Migrate to Grafana Alloy as the recommended replacement for log forwarding.
Changes: - Add alloy/config.alloy.example configuration - Move promtail/run.sh to alloy/run.sh - Update logging.yml to use Alloy - Remove promtail/config.yml.example
1 parent ad3e032 commit 47123ef

File tree

4 files changed

+112
-62
lines changed

4 files changed

+112
-62
lines changed

alloy/config.alloy.example

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
discovery.docker "docker" {
2+
host = "unix:///var/run/docker.sock"
3+
}
4+
5+
loki.process "docker" {
6+
forward_to = [loki.write.default.receiver]
7+
8+
stage.docker { }
9+
}
10+
11+
discovery.relabel "docker" {
12+
targets = []
13+
14+
rule {
15+
source_labels = ["__meta_docker_container_label_promtail_monitored"]
16+
regex = "true"
17+
action = "keep"
18+
}
19+
20+
rule {
21+
source_labels = ["__meta_docker_container_name"]
22+
regex = "/(.*)"
23+
target_label = "container"
24+
}
25+
26+
rule {
27+
source_labels = ["container"]
28+
regex = ".*charon.*"
29+
target_label = "job"
30+
replacement = "charon"
31+
}
32+
33+
rule {
34+
source_labels = ["container"]
35+
regex = ".*nethermind.*"
36+
target_label = "job"
37+
replacement = "nethermind"
38+
}
39+
40+
rule {
41+
source_labels = ["container"]
42+
regex = ".*lodestar.*"
43+
target_label = "job"
44+
replacement = "lodestar"
45+
}
46+
47+
rule {
48+
source_labels = ["container"]
49+
regex = ".*lighthouse.*"
50+
target_label = "job"
51+
replacement = "lighthouse"
52+
}
53+
54+
rule {
55+
source_labels = ["container"]
56+
regex = ".*mev-boost.*"
57+
target_label = "job"
58+
replacement = "mev-boost"
59+
}
60+
61+
rule {
62+
target_label = "cluster_name"
63+
replacement = "$CLUSTER_NAME"
64+
}
65+
66+
rule {
67+
target_label = "cluster_peer"
68+
replacement = "$CLUSTER_PEER"
69+
}
70+
}
71+
72+
loki.source.docker "docker" {
73+
host = "unix:///var/run/docker.sock"
74+
targets = discovery.docker.docker.targets
75+
forward_to = [loki.process.docker.receiver]
76+
relabel_rules = discovery.relabel.docker.rules
77+
}
78+
79+
loki.write "default" {
80+
endpoint {
81+
url = "$CHARON_LOKI_ADDRESSES"
82+
}
83+
external_labels = {}
84+
}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
#!/bin/sh
22

3-
if [ -z "$CHARON_LOKI_ADDRESSES" ]; then
3+
if [ -z "${CHARON_LOKI_ADDRESSES:-}" ]; then
44
echo "Error: \$CHARON_LOKI_ADDRESSES variable is empty" >&2
55
exit 1
66
fi
77

8-
if [ -z "$CLUSTER_NAME" ]; then
8+
if [ -z "${CLUSTER_NAME:-}" ]; then
99
echo "Error: \$CLUSTER_NAME variable is empty" >&2
1010
exit 1
1111
fi
1212

13-
if [ -z "$CLUSTER_PEER" ]; then
13+
if [ -z "${CLUSTER_PEER:-}" ]; then
1414
echo "Error: \$CLUSTER_PEER variable is empty" >&2
1515
exit 1
1616
fi
1717

18-
# Process the template file once
18+
SRC="/etc/alloy/config.alloy.example"
19+
DST="/etc/alloy/config.alloy"
20+
21+
echo "Rendering template: $SRC -> $DST"
22+
1923
sed -e "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \
2024
-e "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
2125
-e "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
22-
/etc/promtail/config.yml.example > /etc/promtail/config.yml
26+
"$SRC" > "$DST"
2327

24-
# Start Promtail with the generated config
25-
/usr/bin/promtail \
26-
-config.file=/etc/promtail/config.yml
28+
echo "Config successfully rendered to $DST"

logging.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
services:
2+
templater:
3+
image: alpine:3.22.2
4+
environment:
5+
CHARON_LOKI_ADDRESSES: ${CHARON_LOKI_ADDRESSES}
6+
CLUSTER_NAME: ${CLUSTER_NAME}
7+
CLUSTER_PEER: ${CLUSTER_PEER}
8+
volumes:
9+
- ./alloy:/etc/alloy
10+
entrypoint: ["/bin/sh", "-lc"]
11+
command: |
12+
chmod +x /etc/alloy/run.sh
13+
/etc/alloy/run.sh
14+
restart: "no"
215

3-
promtail:
4-
image: grafana/promtail:${PROMTAIL_VERSION:-2.8.2}
16+
alloy:
17+
image: grafana/alloy:${ALLOY_VERSION:-v1.11.3}
518
environment:
619
CHARON_LOKI_ADDRESSES: ${CHARON_LOKI_ADDRESSES}
720
CLUSTER_NAME: ${CLUSTER_NAME}
821
CLUSTER_PEER: ${CLUSTER_PEER}
9-
command: -config.file=/etc/promtail/config.yml
22+
command: run /etc/alloy/config.alloy --storage.path=/var/lib/alloy/data
1023
volumes:
11-
- ./promtail:/etc/promtail
24+
- ./alloy:/etc/alloy
1225
- /var/run/docker.sock:/var/run/docker.sock
1326
networks: [dvnode]
14-
entrypoint: /etc/promtail/run.sh
27+
entrypoint: /etc/alloy/run.sh
1528
restart: unless-stopped
1629

1730
networks:

promtail/config.yml.example

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)