-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.yaml
89 lines (81 loc) · 2.43 KB
/
stack.yaml
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
# An example docker-compose file that can be used to run the stack.
# Run with: docker stack deploy -c stack.yaml stack
version: '3.9'
services:
# Some random service that exits after 10 seconds.
# This is used to demonstrate the stack.
dummy:
image: alpine
command: /bin/sh -c "sleep 10 && echo 'I am done'"
deploy:
mode: replicated
replicas: 4
placement:
max_replicas_per_node: 1
prometheus:
image: prom/prometheus:v2.32.1
hostname: prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
# Mount a data volume to persist data between container restarts
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml' # Prometheus configuration
- '--storage.tsdb.retention.time=1y' # Keep data for 1 year
- '--storage.tsdb.path=/prometheus' # Store data in /prometheus
deploy:
mode: global
placement:
constraints:
- node.role == manager
grafana:
image: grafana/grafana:9.1.8
volumes:
# Mount the provisioning config to the container
- ./grafana/provisioning:/etc/grafana/provisioning
env_file:
# Runtime environment variables
- grafana/.env
ports:
- 3000:3000
deploy:
mode: global
placement:
constraints:
- node.role == manager
# The stack monitor.
# Run `docker build -t stack-monitor .` to build the image.
stack-monitor:
image: stack-monitor
environment:
- STACK=stack
- OUTPUT=/usr/share/nginx/html/metrics.txt
volumes:
# Mount a volume under the shared nginx dir to serve static files
- stack_monitor_staticfiles:/usr/share/nginx/html/
# Mount the Docker socket to be able to query the Docker API
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
placement:
constraints:
- node.role == manager
# The nginx proxy that serves the stack monitor metrics.
stack-monitor-nginx:
image: nginx:alpine
hostname: stack-monitor-nginx
volumes:
# Mount a volume under the shared nginx dir to serve static files
- stack_monitor_staticfiles:/usr/share/nginx/html/
ports:
- 80:80
deploy:
mode: global
placement:
constraints:
- node.role == manager
volumes:
prometheus_data:
name: prometheus-data
stack_monitor_staticfiles:
name: stack_monitor_staticfiles