Skip to content

Commit a9b7886

Browse files
committed
Create docker image for Alloy
1 parent f1b45ca commit a9b7886

File tree

15 files changed

+38
-186
lines changed

15 files changed

+38
-186
lines changed

.github/workflows/observability-docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ jobs:
2929
context: observability/traefik
3030
dockerfile: observability/traefik/Dockerfile
3131
image: cogstacksystems/cogstack-observability-traefik
32+
- name: alloy
33+
context: observability/grafana-alloy
34+
dockerfile: observability/grafana-alloy/Dockerfile
35+
image: cogstacksystems/cogstack-observability-alloy
3236
steps:
3337
- name: Checkout branch
3438
uses: actions/checkout@v4

observability/build-docker.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ docker build -t cogstacksystems/cogstack-observability-blackbox-exporter:latest
55

66
docker build -t cogstacksystems/cogstack-observability-grafana:latest -f grafana/Dockerfile ./grafana
77

8-
docker build -t cogstacksystems/cogstack-observability-traefik:latest -f traefik/Dockerfile ./traefik
8+
docker build -t cogstacksystems/cogstack-observability-traefik:latest -f traefik/Dockerfile ./traefik
9+
10+
docker build -t cogstacksystems/cogstack-observability-alloy:latest -f grafana-alloy/Dockerfile ./grafana-alloy --debug

observability/examples/alloy/docker-compose.yml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@ services:
55
prometheus:
66
image: cogstacksystems/cogstack-observability-prometheus:latest
77
restart: unless-stopped
8-
ports:
9-
- "9090:9090"
108
volumes:
11-
- ${BASE_DIR-.}/prometheus:/etc/prometheus/cogstack/site/
9+
- ./prometheus:/etc/prometheus/cogstack/site/
1210
- prometheus-data:/prometheus
1311
networks:
1412
- observability
15-
command:
16-
- "--config.file=/etc/prometheus/cogstack/defaults/prometheus.yml"
17-
- "--storage.tsdb.path=/prometheus"
18-
- "--storage.tsdb.retention.time=30d"
19-
- "--web.external-url=/prometheus"
20-
- "--web.route-prefix=/prometheus"
21-
- "--web.enable-remote-write-receiver"
2213
grafana:
2314
image: cogstacksystems/cogstack-observability-grafana:latest
2415
restart: unless-stopped
@@ -38,36 +29,22 @@ services:
3829
- "80:80"
3930
volumes:
4031
- /var/run/docker.sock:/var/run/docker.sock:ro # So that Traefik can listen to the Docker events
41-
blackbox-exporter:
42-
image: cogstacksystems/cogstack-observability-blackbox-exporter:latest
43-
restart: unless-stopped
44-
networks:
45-
- observability
4632
alloy:
47-
image: grafana/alloy:latest
48-
command:
49-
- run
50-
- --server.http.listen-addr=0.0.0.0:12345
51-
- --storage.path=/var/lib/alloy/data
52-
- --server.http.ui-path-prefix=/alloy
53-
- /etc/alloy
33+
image: cogstacksystems/cogstack-observability-alloy:latest
5434
ports:
5535
- "12345:12345"
5636
volumes:
57-
- ${BASE_DIR-.}/grafana-alloy:/etc/alloy
37+
- ${BASE_DIR-.}/grafana-alloy/probes:/etc/alloy/probes
5838
# - ${BASE_DIR-.}/grafana-alloy/advanced/elasticsearch.alloy:/etc/alloy/elasticsearch.alloy # Enable Elastic Exporter
5939
# CAdvisor
6040
- /:/rootfs:ro
6141
- /var/run:/var/run:rw
6242
- /sys:/sys:ro
6343
- /var/lib/docker/:/var/lib/docker:ro
64-
labels:
65-
- "traefik.enable=true"
66-
- "traefik.http.routers.alloy.rule=PathPrefix(`/alloy`)"
6744
environment:
68-
- PROMETHEUS_URL=${PROMETHEUS_URL-http://cogstack-observability-prometheus-1:9090/prometheus/api/v1/write}
69-
- ALLOY_HOSTNAME=${ALLOY_HOSTNAME} # Used to add a label to metrics
70-
- ALLOY_IP_ADDRESS=${ALLOY_IP_ADDRESS} # Used to add a label to metrics
45+
- PROMETHEUS_URL=http://cogstack-observability-prometheus-1:9090/prometheus
46+
- ALLOY_HOSTNAME=${ALLOY_HOSTNAME-localhost} # Used to add a label to metrics
47+
- ALLOY_IP_ADDRESS=${ALLOY_IP_ADDRESS-localhost} # Used to add a label to metrics
7148
networks:
7249
- observability
7350
networks:

observability/examples/alloy/grafana-alloy/probes/probe-external.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,5 @@
22
- targets:
33
- https://cogstack.org
44
labels:
5-
name: cogstack-homepage
6-
job: probe-services-alloy
7-
- targets:
8-
- https://cogstack.org
9-
labels:
10-
name: admin_probe
11-
job: probe-services-alloy-2
12-
module: http_admin_get_200
5+
name: homepage
6+
job: probe-services

observability/examples/alloy/prometheus/scrape-configs/probers/probe-internal.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM grafana/alloy:latest
2+
3+
LABEL traefik.enable="true" \
4+
traefik.http.routers.alloy.rule="PathPrefix(`/alloy`)"
5+
6+
COPY ./defaults /etc/alloy
7+
8+
CMD [ \
9+
"run", \
10+
"--server.http.listen-addr=0.0.0.0:12345", \
11+
"--storage.path=/var/lib/alloy/data", \
12+
"--server.http.ui-path-prefix=/alloy", \
13+
"/etc/alloy" \
14+
]
15+
16+
ENV PROMETHEUS_URL=http://cogstack-observability-prometheus-1:9090/prometheus

observability/examples/alloy/grafana-alloy/config.alloy renamed to observability/grafana-alloy/defaults/config.alloy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ livedebugging {
99

1010
prometheus.remote_write "default" {
1111
endpoint {
12-
url = sys.env("PROMETHEUS_URL")
12+
url = sys.env("PROMETHEUS_URL") + "/api/v1/write"
1313
}
1414
external_labels = {
1515
host = sys.env("ALLOY_HOSTNAME"),

observability/examples/alloy/grafana-alloy/probe-default-config.alloy renamed to observability/grafana-alloy/defaults/probe-default-config.alloy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Blackbox Exporter - Probe Observability Stack
33
prometheus.exporter.blackbox "probe_observability_stack" {
4-
config_file = "/etc/alloy/blackbox.yml"
4+
config_file = "/etc/alloy/blackbox-exporter.yml"
55
target {
66
name = "grafana"
77
address = "cogstack-observability-traefik-1/grafana/api/health"
@@ -60,7 +60,7 @@ discovery.relabel "probe_target_files_with_defaults" {
6060
source_labels = ["module"]
6161
target_label = "module"
6262
regex = ""
63-
replacement = "http_200_ok"
63+
replacement = "http_get_200"
6464
}
6565
rule {
6666
// Alloy takes the "name" field from the yml file, puts it into the job field as a suffix, then removes name. This brings name back.
@@ -70,7 +70,7 @@ discovery.relabel "probe_target_files_with_defaults" {
7070
}
7171

7272
prometheus.exporter.blackbox "probe_discovered_targets" {
73-
config_file = "/etc/alloy/blackbox.yml"
73+
config_file = "/etc/alloy/blackbox-exporter.yml"
7474
targets = discovery.relabel.probe_target_files_with_defaults.output
7575
}
7676

observability/grafana/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ ENV GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboar
1717
ALERTING_PAUSE_BURN_RATE=true \
1818
ALERTING_DEFAULT_CONTACT=Slack \
1919
SLACK_WEBHOOK_URL=http://localhost:3000/missing-SLACK_WEBHOOK_URL-env-var \
20-
PROMETHEUS_DATASOURCE_URL=http://cogstack-observability-prometheus-1:9090/prometheus
20+
PROMETHEUS_URL=http://cogstack-observability-prometheus-1:9090/prometheus

0 commit comments

Comments
 (0)