Skip to content

Commit 8438044

Browse files
committed
refine docs, shell, and makefile
Signed-off-by: JaredforReal <[email protected]>
1 parent 6508996 commit 8438044

File tree

4 files changed

+40
-35
lines changed

4 files changed

+40
-35
lines changed

tools/make/observability.mk

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ OBS_CONFIG_DIR = tools/observability
77
OBS_SCRIPTS_DIR = tools/observability/scripts
88

99
.PHONY: run-observability stop-observability \
10-
obs-local obs-compose obs-logs obs-status obs-clean \
1110
o11y-local o11y-compose o11y-logs o11y-status o11y-clean open-observability
1211

1312
## run-observability: Start observability stack (alias for o11y-local)
@@ -18,21 +17,11 @@ o11y-local:
1817
@$(call log, Starting observability in LOCAL mode...)
1918
@$(OBS_SCRIPTS_DIR)/start-observability.sh local
2019

21-
## obs-local: Alias for o11y-local (deprecated name)
22-
obs-local:
23-
@echo "Note: 'obs-local' is deprecated, use 'o11y-local' instead"
24-
@$(MAKE) o11y-local
25-
2620
## o11y-compose: Start observability in COMPOSE mode (all services in Docker)
2721
o11y-compose:
2822
@$(call log, Starting observability in COMPOSE mode...)
2923
@$(OBS_SCRIPTS_DIR)/start-observability.sh compose
3024

31-
## obs-compose: Alias for o11y-compose (deprecated name)
32-
obs-compose:
33-
@echo "Note: 'obs-compose' is deprecated, use 'o11y-compose' instead"
34-
@$(MAKE) o11y-compose
35-
3625
## stop-observability: Stop and remove observability containers
3726
stop-observability:
3827
@$(call log, Stopping observability stack...)
@@ -46,33 +35,18 @@ open-observability:
4635

4736
## o11y-logs: Show logs from observability containers
4837
o11y-logs:
49-
@docker compose -f $(PWD)/docker-compose.obs.yml logs -f 2>/dev/null || docker compose logs prometheus grafana -f
50-
51-
## obs-logs: Alias for o11y-logs (deprecated name)
52-
obs-logs:
53-
@echo "Note: 'obs-logs' is deprecated, use 'o11y-logs' instead"
54-
@$(MAKE) o11y-logs
38+
@docker compose -f docker-compose.obs.yml logs -f 2>/dev/null || docker compose logs prometheus grafana -f
5539

5640
## o11y-status: Check status of observability containers
5741
o11y-status:
5842
@echo "==> Local mode:"
59-
@docker compose -f $(PWD)/docker-compose.obs.yml ps 2>/dev/null || echo " Not running"
43+
@docker compose -f docker-compose.obs.yml ps 2>/dev/null || echo " Not running"
6044
@echo ""
6145
@echo "==> Compose mode:"
6246
@docker compose ps prometheus grafana 2>/dev/null || echo " Not running"
6347

64-
## obs-status: Alias for o11y-status (deprecated name)
65-
obs-status:
66-
@echo "Note: 'obs-status' is deprecated, use 'o11y-status' instead"
67-
@$(MAKE) o11y-status
68-
6948
## o11y-clean: Remove observability data volumes
7049
o11y-clean:
7150
@echo "⚠️ Removing all observability data volumes..."
7251
@docker volume rm prometheus-local-data grafana-local-data prometheus-data grafana-data 2>/dev/null || true
7352
@echo "✓ Done"
74-
75-
## obs-clean: Alias for o11y-clean (deprecated name)
76-
obs-clean:
77-
@echo "Note: 'obs-clean' is deprecated, use 'o11y-clean' instead"
78-
@$(MAKE) o11y-clean

tools/observability/scripts/start-observability.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ MODE="${1:-local}"
4848
case "${MODE}" in
4949
local)
5050
log_info "Starting observability in LOCAL mode (router on host, observability in Docker)"
51-
COMPOSE_CMD="docker compose -f ${PROJECT_ROOT}/docker-compose.obs.yml"
51+
COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.obs.yml"
5252
;;
5353
compose)
5454
log_info "Starting observability in COMPOSE mode (all services in Docker)"
55-
COMPOSE_CMD="docker compose -f ${PROJECT_ROOT}/docker-compose.yml"
55+
COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
5656
;;
5757
*)
5858
log_error "Invalid mode: ${MODE}"
@@ -78,9 +78,9 @@ if ! docker info &> /dev/null; then
7878
fi
7979

8080
log_info "Starting services..."
81-
log_debug "Command: ${COMPOSE_CMD} up -d"
81+
log_debug "Command: docker compose -f \"${COMPOSE_FILE}\" up -d"
8282

83-
${COMPOSE_CMD} up -d
83+
docker compose -f "${COMPOSE_FILE}" up -d
8484

8585
# Wait for services to become healthy
8686
log_info "Waiting for services to become healthy..."

tools/observability/scripts/stop-observability.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,48 @@ echo -e "${BLUE} Stopping Observability Stack${NC}"
3434
echo -e "${BLUE}==================================================================${NC}"
3535
echo ""
3636

37+
# Helpers
38+
container_exists() {
39+
# Returns 0 if a container with the given name exists (in any state)
40+
docker ps -a --format '{{.Names}}' | grep -Fxq "$1"
41+
}
42+
43+
any_container_exists() {
44+
# Returns 0 if any of the provided container names exist
45+
local name
46+
for name in "$@"; do
47+
if container_exists "$name"; then
48+
return 0
49+
fi
50+
done
51+
return 1
52+
}
53+
3754
# Stop services
3855
log_info "Stopping observability services..."
3956

4057
# Try stopping local mode containers first
41-
if docker ps -a --format '{{.Names}}' | grep -qE '^(prometheus-local|grafana-local)$'; then
58+
LOCAL_MODE_RUNNING=false
59+
if any_container_exists "prometheus-local" "grafana-local"; then
60+
LOCAL_MODE_RUNNING=true
61+
fi
62+
if [ "${LOCAL_MODE_RUNNING}" = true ]; then
4263
log_info "Stopping local mode containers..."
4364
docker compose -f "${PROJECT_ROOT}/docker-compose.obs.yml" down
4465
fi
4566

4667
# Also stop compose mode if running as part of main stack
47-
if docker ps -a --format '{{.Names}}' | grep -qE '^(prometheus|grafana)$' && ! docker ps -a --format '{{.Names}}' | grep -q 'semantic-router'; then
68+
COMPOSE_O11Y_RUNNING=false
69+
if any_container_exists "prometheus" "grafana"; then
70+
COMPOSE_O11Y_RUNNING=true
71+
fi
72+
73+
ROUTER_RUNNING=false
74+
if container_exists "semantic-router"; then
75+
ROUTER_RUNNING=true
76+
fi
77+
78+
if [ "${COMPOSE_O11Y_RUNNING}" = true ] && [ "${ROUTER_RUNNING}" = false ]; then
4879
log_warn "Observability containers from main stack are running"
4980
log_info "Use 'docker compose down' to stop the full stack"
5081
fi

website/docs/tutorials/observability/observability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ make stop-observability
5353

5454
All configs in `tools/observability/`:
5555

56-
- `prometheus.yaml` - Scrapes `localhost:9190` when `ROUTER_TARGET=localhost:9190`
56+
- `prometheus.yaml` - Scrapes the target from the `ROUTER_TARGET` env var (default: `localhost:9190`)
5757
- `grafana-datasource.yaml` - Points to `localhost:9090`
5858
- `grafana-dashboard.yaml` - Dashboard provisioning
5959
- `llm-router-dashboard.json` - Dashboard definition

0 commit comments

Comments
 (0)