Skip to content

Commit 3c57f9b

Browse files
committed
refactor obser for Compose and add for Local
Signed-off-by: JaredforReal <[email protected]>
1 parent 94a9d39 commit 3c57f9b

16 files changed

+1744
-232
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ _run:
1616
-f tools/make/pre-commit.mk \
1717
-f tools/make/docker.mk \
1818
-f tools/make/kube.mk \
19+
-f tools/make/observability.mk \
1920
$(MAKECMDGOALS)
2021

2122
.PHONY: _run

config/grafana/dashboards.yaml

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

config/grafana/datasource.yaml

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

config/prometheus.yaml

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

docker-compose.obs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Local observability stack for monitoring semantic-router running on host
2+
#
3+
# Usage: make obs-local
4+
# Or: docker compose -f docker-compose.obs.yml up
5+
#
6+
# This provides Prometheus and Grafana in Docker with network_mode: host
7+
# to scrape metrics from router running natively on localhost:9190
8+
9+
version: '3.8'
10+
11+
services:
12+
prometheus:
13+
image: prom/prometheus:v2.53.0
14+
container_name: prometheus-local
15+
network_mode: host
16+
volumes:
17+
- ./tools/observability/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
18+
- prometheus-local-data:/prometheus
19+
command:
20+
- '--config.file=/etc/prometheus/prometheus.yaml'
21+
- '--storage.tsdb.path=/prometheus'
22+
- '--storage.tsdb.retention.time=15d'
23+
environment:
24+
- ROUTER_TARGET=localhost:9190
25+
26+
grafana:
27+
image: grafana/grafana:11.5.1
28+
container_name: grafana-local
29+
network_mode: host
30+
volumes:
31+
- ./tools/observability/grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml:ro
32+
- ./tools/observability/grafana-dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml:ro
33+
- ./tools/observability/llm-router-dashboard.json:/etc/grafana/provisioning/dashboards/llm-router-dashboard.json:ro
34+
- grafana-local-data:/var/lib/grafana
35+
environment:
36+
- PROMETHEUS_URL=localhost:9090
37+
- GF_SECURITY_ADMIN_PASSWORD=admin
38+
- GF_USERS_ALLOW_SIGN_UP=false
39+
40+
volumes:
41+
prometheus-local-data:
42+
grafana-local-data:

docker-compose.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ services:
6969
image: prom/prometheus:v2.53.0
7070
container_name: prometheus
7171
volumes:
72-
- ./config/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
72+
- ./tools/observability/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
73+
- prometheus-data:/prometheus
7374
command:
7475
- --config.file=/etc/prometheus/prometheus.yaml
7576
- --storage.tsdb.retention.time=15d
77+
environment:
78+
- ROUTER_TARGET=semantic-router:9190
7679
ports:
7780
- "9090:9090"
7881
networks:
@@ -84,14 +87,18 @@ services:
8487
environment:
8588
- GF_SECURITY_ADMIN_USER=admin
8689
- GF_SECURITY_ADMIN_PASSWORD=admin
90+
- PROMETHEUS_URL=prometheus:9090
8791
ports:
8892
- "3000:3000"
8993
volumes:
90-
- ./config/grafana/datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml:ro
91-
- ./config/grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml:ro
92-
- ./deploy/llm-router-dashboard.json:/etc/grafana/provisioning/dashboards/llm-router-dashboard.json:ro
94+
- ./tools/observability/grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml:ro
95+
- ./tools/observability/grafana-dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml:ro
96+
- ./tools/observability/llm-router-dashboard.json:/etc/grafana/provisioning/dashboards/llm-router-dashboard.json:ro
97+
- grafana-data:/var/lib/grafana
9398
networks:
9499
- semantic-network
100+
depends_on:
101+
- prometheus
95102

96103
# LLM Katan service for testing
97104
llm-katan:
@@ -118,3 +125,5 @@ networks:
118125
volumes:
119126
models-cache:
120127
driver: local
128+
prometheus-data:
129+
grafana-data:

tools/make/common.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ help:
8585
@echo " docs-serve - Serve built documentation"
8686
@echo " docs-clean - Clean documentation artifacts"
8787
@echo ""
88+
@echo " Observability targets:"
89+
@echo " run-observability - Start observability (alias for obs-local)"
90+
@echo " obs-local - Start observability in LOCAL mode"
91+
@echo " obs-compose - Start observability in COMPOSE mode"
92+
@echo " stop-observability - Stop observability stack"
93+
@echo " open-observability - Open Prometheus and Grafana in browser"
94+
@echo " obs-status - Check observability stack status"
95+
@echo " obs-logs - Show observability logs"
96+
@echo " obs-clean - Remove observability data volumes"
97+
@echo ""
8898
@echo " Environment variables:"
8999
@echo " CONTAINER_RUNTIME - Container runtime (docker|podman, default: docker)"
90100
@echo " CONFIG_FILE - Config file path (default: config/config.yaml)"

tools/make/observability.mk

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ====================== observability.mk ======================
2+
# = Observability targets for semantic-router monitoring =
3+
# ====================== observability.mk ======================
4+
5+
# Observability directories
6+
OBS_CONFIG_DIR = tools/observability
7+
OBS_SCRIPTS_DIR = tools/observability/scripts
8+
9+
.PHONY: run-observability stop-observability obs-local obs-compose open-observability obs-logs obs-status obs-clean
10+
11+
## run-observability: Start observability stack (alias for obs-local)
12+
run-observability: obs-local
13+
14+
## obs-local: Start observability in LOCAL mode (router on host, obs in Docker)
15+
obs-local:
16+
@$(call log, Starting observability in LOCAL mode...)
17+
@$(OBS_SCRIPTS_DIR)/start-observability.sh local
18+
19+
## obs-compose: Start observability in COMPOSE mode (all services in Docker)
20+
obs-compose:
21+
@$(call log, Starting observability in COMPOSE mode...)
22+
@$(OBS_SCRIPTS_DIR)/start-observability.sh compose
23+
24+
## stop-observability: Stop and remove observability containers
25+
stop-observability:
26+
@$(call log, Stopping observability stack...)
27+
@$(OBS_SCRIPTS_DIR)/stop-observability.sh
28+
29+
## open-observability: Open Prometheus and Grafana in browser
30+
open-observability:
31+
@echo "Opening Prometheus and Grafana..."
32+
@open http://localhost:9090 2>/dev/null || xdg-open http://localhost:9090 2>/dev/null || echo "Please open http://localhost:9090"
33+
@open http://localhost:3000 2>/dev/null || xdg-open http://localhost:3000 2>/dev/null || echo "Please open http://localhost:3000"
34+
35+
## obs-logs: Show logs from observability containers
36+
obs-logs:
37+
@docker compose -f docker-compose.obs.yml logs -f 2>/dev/null || docker compose logs prometheus grafana -f
38+
39+
## obs-status: Check status of observability containers
40+
obs-status:
41+
@echo "==> Local mode:"
42+
@docker compose -f docker-compose.obs.yml ps 2>/dev/null || echo " Not running"
43+
@echo ""
44+
@echo "==> Compose mode:"
45+
@docker compose ps prometheus grafana 2>/dev/null || echo " Not running"
46+
47+
## obs-clean: Remove observability data volumes
48+
obs-clean:
49+
@echo "⚠️ Removing all observability data volumes..."
50+
@docker volume rm prometheus-local-data grafana-local-data prometheus-data grafana-data 2>/dev/null || true
51+
@echo "✓ Done"

tools/observability/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Observability Configuration
2+
3+
Prometheus and Grafana configuration files for monitoring semantic-router.
4+
5+
## Files
6+
7+
- `prometheus.yaml` - Prometheus scrape config (uses `$ROUTER_TARGET` env var)
8+
- `grafana-datasource.yaml` - Grafana datasource (uses `$PROMETHEUS_URL` env var)
9+
- `grafana-dashboard.yaml` - Dashboard provisioning config
10+
- `llm-router-dashboard.json` - LLM Router dashboard
11+
12+
## Usage
13+
14+
**Local mode** (router on host, observability in Docker):
15+
16+
```bash
17+
make obs-local
18+
```
19+
20+
**Compose mode** (all services in Docker):
21+
22+
```bash
23+
make obs-compose
24+
# or: docker compose up
25+
```
26+
27+
**Access:**
28+
29+
- Prometheus: http://localhost:9090
30+
- Grafana: http://localhost:3000 (admin/admin)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Grafana dashboard provisioning configuration
2+
# This file tells Grafana where to find dashboard JSON files
3+
4+
apiVersion: 1
5+
6+
providers:
7+
- name: "Semantic Router"
8+
orgId: 1
9+
folder: ""
10+
type: file
11+
disableDeletion: false
12+
updateIntervalSeconds: 10
13+
allowUiUpdates: true
14+
options:
15+
path: /etc/grafana/provisioning/dashboards

0 commit comments

Comments
 (0)