Skip to content

Commit 76bda9d

Browse files
author
Simon Bordeyne
committed
tooling: add log generator and collection to compose.yaml
1 parent 45f479f commit 76bda9d

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.alloy/config.alloy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
livedebugging {
2+
enabled = true
3+
}
4+
5+
discovery.docker "linux" {
6+
host = "unix:///var/run/docker.sock"
7+
}
8+
9+
discovery.relabel "logs_integrations_docker" {
10+
targets = []
11+
12+
rule {
13+
source_labels = ["__meta_docker_container_name"]
14+
regex = "/(.*)"
15+
target_label = "service_name"
16+
}
17+
}
18+
19+
loki.source.docker "default" {
20+
host = "unix:///var/run/docker.sock"
21+
targets = discovery.docker.linux.targets
22+
labels = {"platform" = "docker"}
23+
relabel_rules = discovery.relabel.logs_integrations_docker.rules
24+
forward_to = [loki.process.logs.receiver]
25+
}
26+
27+
loki.process "logs" {
28+
stage.static_labels {
29+
values = {
30+
env = "dev",
31+
}
32+
}
33+
34+
forward_to = [loki.write.local.receiver]
35+
}
36+
37+
loki.write "local" {
38+
endpoint {
39+
url = string.format(
40+
"http://victorialogs:9428/insert/loki/api/v1/push?disable_message_parsing=1&_stream_fields=%s",
41+
string.join([
42+
"env",
43+
"platform",
44+
"service_name",
45+
"level",
46+
], ","),
47+
)
48+
}
49+
}

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.ts]
2+
indent_style = space
3+
indent_size = 2

compose.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
services:
2+
# Generate some logs for testing, in JSON format
3+
flog-json:
4+
image: mingrammer/flog:latest
5+
command: ["flog", "-f", "json", "--number", "36000", "--sleep", "100ms"]
6+
# Run Grafana Alloy to collect logs from Docker and forward them to VictoriaLogs
7+
alloy:
8+
image: grafana/alloy:latest
9+
privileged: true
10+
ports:
11+
- 12345:12345
12+
- 4317:4317
13+
- 4318:4318
14+
volumes:
15+
- ./.alloy/config.alloy:/etc/alloy/config.alloy:ro
16+
- /proc:/rootproc:ro
17+
- /var/run/docker.sock.raw:/var/run/docker.sock
18+
- /sys:/sys:ro
19+
- /:/rootfs:ro
20+
- /dev/disk/:/dev/disk:ro
21+
- /var/lib/docker/:/var/lib/docker:ro
22+
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy
23+
extra_hosts:
24+
- "host.docker.internal:host-gateway"
25+
devices:
26+
- /dev/kmsg
227
socks-proxy:
328
image: serjs/go-socks5-proxy
429
restart: always
30+
environment:
31+
REQUIRE_AUTH: "false"
532
victorialogs:
633
image: victoriametrics/victoria-logs:v1.26.0
734
ports:

0 commit comments

Comments
 (0)