Skip to content

Commit 5de738e

Browse files
committed
Run Grafana alloy to replace exporters
1 parent 7cd422f commit 5de738e

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

observability/build-docker.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
docker build -t cogstacksystems/cogstack-observability-prometheus:latest -f prometheus/Dockerfile.prometheus ./prometheus
3+
4+
docker build -t cogstacksystems/cogstack-observability-blackbox-exporter:latest -f prometheus/Dockerfile.blackbox ./prometheus
5+
6+
docker build -t cogstacksystems/cogstack-observability-grafana:latest -f grafana/Dockerfile ./grafana
7+
8+
docker build -t cogstacksystems/cogstack-observability-traefik:latest -f traefik/Dockerfile ./traefik

observability/examples/full/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
prometheus:
66
image: cogstacksystems/cogstack-observability-prometheus:latest
77
restart: unless-stopped
8+
ports:
9+
- "9090:9090"
810
volumes:
911
- ./prometheus:/etc/prometheus/cogstack/site/
1012
- prometheus-data:/prometheus
@@ -29,6 +31,30 @@ services:
2931
- "80:80"
3032
volumes:
3133
- /var/run/docker.sock:/var/run/docker.sock:ro # So that Traefik can listen to the Docker events
34+
alloy:
35+
image: grafana/alloy:latest
36+
command:
37+
- run
38+
- --server.http.listen-addr=0.0.0.0:12345
39+
- --storage.path=/var/lib/alloy/data
40+
- --server.http.ui-path-prefix=/alloy
41+
- /etc/alloy/config.alloy
42+
ports:
43+
- "12345:12345"
44+
volumes:
45+
- ./grafana-alloy/config.alloy:/etc/alloy/config.alloy
46+
# CAdvisor
47+
- /:/rootfs:ro
48+
- /var/run:/var/run:rw
49+
- /sys:/sys:ro
50+
- /var/lib/docker/:/var/lib/docker:ro
51+
labels:
52+
- "traefik.enable=true"
53+
- "traefik.http.routers.cadvisor.rule=PathPrefix(`/alloy`)"
54+
environment:
55+
- PROMETHEUS_URL=http://cogstack-observability-prometheus-1:9090/prometheus/api/v1/write
56+
networks:
57+
- observability
3258
networks:
3359
observability:
3460
driver: bridge
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
logging {
2+
level = "debug"
3+
format = "logfmt"
4+
}
5+
6+
prometheus.remote_write "default" {
7+
endpoint {
8+
url = sys.env("PROMETHEUS_URL")
9+
}
10+
}
11+
12+
prometheus.scrape "exporter" {
13+
14+
scrape_interval = "15s"
15+
16+
targets = array.concat(
17+
prometheus.exporter.self.alloy.targets,
18+
prometheus.exporter.cadvisor.local_cadvisor.targets,
19+
prometheus.exporter.unix.local_node_exporter.targets,
20+
)
21+
forward_to = [prometheus.remote_write.default.receiver]
22+
}
23+
24+
// Alloys internal metrics
25+
prometheus.exporter.self "alloy" {
26+
}
27+
28+
// CAdvisor
29+
prometheus.exporter.cadvisor "local_cadvisor" {
30+
docker_host = "unix:///var/run/docker.sock"
31+
storage_duration = "5m"
32+
}
33+
34+
// Node exporter
35+
prometheus.exporter.unix "local_node_exporter" {
36+
}

observability/prometheus/Dockerfile.prometheus

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ CMD [ \
1010
"--storage.tsdb.path=/prometheus", \
1111
"--storage.tsdb.retention.time=30d", \
1212
"--web.external-url=/prometheus", \
13-
"--web.route-prefix=/prometheus" \
13+
"--web.route-prefix=/prometheus", \
14+
"--web.enable-remote-write-receiver" \
1415
]

0 commit comments

Comments
 (0)