Skip to content

Commit 1420ad9

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 1420ad9

File tree

5 files changed

+126
-81
lines changed

5 files changed

+126
-81
lines changed

alloy/config.alloy.example

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 = discovery.docker.docker.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+
cluster_name = "$CLUSTER_NAME",
85+
cluster_peer = "$CLUSTER_PEER",
86+
}
87+
}

alloy/run.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
SRC="/etc/alloy/config.alloy.example"
19+
DST="/etc/alloy/config.alloy"
20+
21+
echo "Rendering template: $SRC -> $DST"
22+
23+
sed -e "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \
24+
-e "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
25+
-e "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
26+
"$SRC" > "$DST"
27+
28+
echo "Config successfully rendered to $DST"
29+
30+
# Execute the command passed as arguments if any
31+
if [ $# -gt 0 ]; then
32+
echo "Executing: $@"
33+
exec "$@"
34+
fi

logging.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
services:
2-
3-
promtail:
4-
image: grafana/promtail:${PROMTAIL_VERSION:-2.8.2}
2+
alloy:
3+
image: grafana/alloy:${ALLOY_VERSION:-v1.11.3}
54
environment:
65
CHARON_LOKI_ADDRESSES: ${CHARON_LOKI_ADDRESSES}
76
CLUSTER_NAME: ${CLUSTER_NAME}
87
CLUSTER_PEER: ${CLUSTER_PEER}
9-
command: -config.file=/etc/promtail/config.yml
108
volumes:
11-
- ./promtail:/etc/promtail
9+
- ./alloy:/etc/alloy
1210
- /var/run/docker.sock:/var/run/docker.sock
1311
networks: [dvnode]
14-
entrypoint: /etc/promtail/run.sh
12+
entrypoint: /etc/alloy/run.sh
13+
command: ["/bin/alloy", "run", "/etc/alloy/config.alloy", "--storage.path=/var/lib/alloy/data"]
1514
restart: unless-stopped
1615

1716
networks:

promtail/config.yml.example

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

promtail/run.sh

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

0 commit comments

Comments
 (0)