Skip to content

Commit c352673

Browse files
committed
Add default labels to alloy scraped metrics
1 parent 4584769 commit c352673

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

observability/examples/alloy/docker-compose.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
ports:
99
- "9090:9090"
1010
volumes:
11-
- ${BASE_PATH-.}/prometheus:/etc/prometheus/cogstack/site/
11+
- ${BASE_DIR-.}/prometheus:/etc/prometheus/cogstack/site/
1212
- prometheus-data:/prometheus
1313
networks:
1414
- observability
@@ -38,6 +38,11 @@ services:
3838
- "80:80"
3939
volumes:
4040
- /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
4146
alloy:
4247
image: grafana/alloy:latest
4348
command:
@@ -49,7 +54,7 @@ services:
4954
ports:
5055
- "12345:12345"
5156
volumes:
52-
- ${BASE_PATH-.}/grafana-alloy/config.alloy:/etc/alloy/config.alloy
57+
- ${BASE_DIR-.}/grafana-alloy/config.alloy:/etc/alloy/config.alloy
5358
# CAdvisor
5459
- /:/rootfs:ro
5560
- /var/run:/var/run:rw
@@ -59,7 +64,9 @@ services:
5964
- "traefik.enable=true"
6065
- "traefik.http.routers.cadvisor.rule=PathPrefix(`/alloy`)"
6166
environment:
62-
- PROMETHEUS_URL=http://cogstack-observability-prometheus-1:9090/prometheus/api/v1/write
67+
- PROMETHEUS_URL=${PROMETHEUS_URL-http://cogstack-observability-prometheus-1:9090/prometheus/api/v1/write}
68+
- ALLOY_HOSTNAME=my-custom-host
69+
- ALLOY_IP_ADDRESS=my-custom-ip
6370
networks:
6471
- observability
6572
networks:

observability/examples/alloy/grafana-alloy/config.alloy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ prometheus.remote_write "default" {
77
endpoint {
88
url = sys.env("PROMETHEUS_URL")
99
}
10+
external_labels = {
11+
host = sys.env("ALLOY_HOSTNAME"),
12+
ip_address = sys.env("ALLOY_IP_ADDRESS"),
13+
}
1014
}
1115

1216
prometheus.scrape "exporter" {
13-
1417
scrape_interval = "15s"
15-
1618
targets = array.concat(
1719
prometheus.exporter.self.alloy.targets,
1820
prometheus.exporter.cadvisor.local_cadvisor.targets,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example of probe targets
2+
- targets:
3+
- https://cogstack.org
4+
labels:
5+
name: cogstack-homepage
6+
job: probe-services
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
groups:
2+
- name: slo-target-rules
3+
rules:
4+
# What SLO am I targeting
5+
- record: slo_target_over_30_days
6+
expr: 0.95 # We target 95% uptime over 30 days
7+
labels:
8+
job: "probe-external-demo-apps" #Job here must match the job in the probe targets

observability/examples/full/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ services:
2929
- "80:80"
3030
volumes:
3131
- /var/run/docker.sock:/var/run/docker.sock:ro # So that Traefik can listen to the Docker events
32+
blackbox-exporter:
33+
image: cogstacksystems/cogstack-observability-blackbox-exporter:latest
34+
restart: unless-stopped
35+
networks:
36+
- observability
3237
networks:
3338
observability:
3439
driver: bridge

0 commit comments

Comments
 (0)