-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
166 lines (161 loc) · 5.86 KB
/
Copy pathdocker-compose.yml
File metadata and controls
166 lines (161 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
services:
# Background data collection service
collector:
build:
context: ./collector
dockerfile: Dockerfile
#user: "0:0" # Run as root
command: ["python", "-m", "src.collector_main"]
environment:
- METRICS_BACKEND=${METRICS_BACKEND:-influxdb}
- INFLUXDB_URL=http://influxdb:8086
- INFLUXDB_TOKEN=${INFLUXDB_TOKEN}
- INFLUXDB_ORG=${INFLUXDB_ORG:-prometheus}
- INFLUXDB_BUCKET=${INFLUXDB_BUCKET:-gpu_metrics}
# Performance tuning for 300+ endpoint scale
- INFLUXDB_BATCH_SIZE=${INFLUXDB_BATCH_SIZE:-0} # 0 = use config.yaml default (10000)
- INFLUXDB_WRITE_TIMEOUT_MS=${INFLUXDB_WRITE_TIMEOUT_MS:-0} # 0 = use config.yaml default (90000 = 90s)
- INFLUXDB_MAX_CONCURRENT_WRITES=${INFLUXDB_MAX_CONCURRENT_WRITES:-0} # 0 = use config.yaml default (5)
- INFLUXDB_FLUSH_INTERVAL_SECONDS=${INFLUXDB_FLUSH_INTERVAL_SECONDS:-0} # 0 = use config.yaml default (10s)
- CONFIG_PATH=/app/config/config.yaml
- SCHEMA_PATH=/app/config/metrics_schema.yaml
- DATABASE_URL=sqlite:///data/targets.db
- ENCRYPTION_KEY=${ENCRYPTION_KEY}
# Alert/Webhook settings (for testing webhook subscriptions)
- ALERT_FORCE_WEBHOOK_MODE=${ALERT_FORCE_WEBHOOK_MODE:-false}
volumes:
- shared_data:/app/data
- ./collector/config:/app/config:ro
depends_on:
influxdb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
restart: unless-stopped
# Resource limits scaled for 300+ endpoints
# For smaller deployments (< 50 endpoints), can reduce to mem_limit: 2g, cpus: 2.
# JSON/JSONPath parsing is GIL-bound and CPU-heavy; under-provisioned CPUs
# starve the asyncio loop and produce silent flush-loop stalls.
mem_limit: 8g
cpus: 4
networks:
- monitoring
# Note: Port 8081 is only exposed internally for health checks, not to host
# Web UI and API service
api:
build:
context: ./collector
dockerfile: Dockerfile
#user: "0:0" # Run as root
command: ["python", "-m", "src.api_main"]
ports:
- "${API_PORT:-8080}:8080"
environment:
- CONFIG_PATH=/app/config/config.yaml
- SCHEMA_PATH=/app/config/metrics_schema.yaml
- DATABASE_URL=sqlite:///data/targets.db
- ENCRYPTION_KEY=${ENCRYPTION_KEY}
- GRAFANA_PORT=${GRAFANA_PORT:-3000}
- INFLUXDB_PORT=${INFLUXDB_PORT:-8086}
- PROMETHEUS_PORT=${PROMETHEUS_PORT:-9090}
volumes:
- shared_data:/app/data
- ./collector/config:/app/config:ro
depends_on:
- collector
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: unless-stopped
mem_limit: 2g
cpus: 0.5
networks:
- monitoring
influxdb:
image: influxdb:2.7.11
#user: "0:0" # Run as root
ports:
- "${INFLUXDB_PORT:-8086}:8086"
environment:
#- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_ADMIN_USER:-admin}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG:-prometheus}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET:-gpu_metrics}
- DOCKER_INFLUXDB_INIT_RETENTION=${INFLUXDB_RETENTION:-7d}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_TOKEN}
- INFLUXDB_TOKEN=${INFLUXDB_TOKEN}
- INFLUXDB_ORG=${INFLUXDB_ORG:-prometheus}
- INFLUXDB_BUCKET=${INFLUXDB_BUCKET:-gpu_metrics}
- INFLUXDB_15M_RETENTION=${INFLUXDB_15M_RETENTION:-30d}
- INFLUXDB_HOURLY_RETENTION=${INFLUXDB_HOURLY_RETENTION:-90d}
- INFLUXDB_HTTP_BIND_ADDRESS=:8086
# Performance tuning for high-volume writes (300+ endpoints)
- INFLUXDB_DATA_CACHE_MAX_MEMORY_SIZE=4294967296 # 4GB cache (increased from 2GB)
- INFLUXDB_DATA_QUERY_CONCURRENCY=20 # Increased from 10
- INFLUXDB_HTTP_MAX_ROW_LIMIT=100000
- INFLUXDB_HTTP_WRITE_TIMEOUT=90s # Match collector timeout
- INFLUXDB_STORAGE_WAL_FSYNC_DELAY=100ms # Batch WAL writes for better performance
volumes:
- influxdb_data:/var/lib/influxdb2
- influxdb_config:/etc/influxdb2
# Temporarily disabled init scripts - run manually after startup with:
# ./gyanam.sh setup-all-downsampling
- ./influxdb/scripts:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8086/ping"]
interval: 10s
timeout: 5s
retries: 10
start_period: 90s
restart: unless-stopped
mem_limit: 16g
# Sustained ~1.6K writes/s at 250-target scale + Grafana queries + TSM
# compaction — InfluxDB needs real CPU to keep flush latency below ~3s.
cpus: 4
networks:
- monitoring
grafana:
image: grafana/grafana:13.0.1
#user: "0:0" # Run as root
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
- INFLUXDB_TOKEN=${INFLUXDB_TOKEN}
- INFLUXDB_ORG=${INFLUXDB_ORG:-prometheus}
- INFLUXDB_BUCKET=${INFLUXDB_BUCKET:-gpu_metrics}
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
depends_on:
influxdb:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
restart: unless-stopped
mem_limit: 4g
cpus: 0.5
networks:
- monitoring
volumes:
shared_data:
influxdb_data:
influxdb_config:
grafana_data:
networks:
monitoring:
driver: bridge