-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitoring-userdata.sh.tpl
More file actions
51 lines (44 loc) · 1.33 KB
/
monitoring-userdata.sh.tpl
File metadata and controls
51 lines (44 loc) · 1.33 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
#!/bin/bash
# Abort on all errors
set -e
# This is not production grade, but for the sake of brevity we are using it like this.
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
# Create shared directory for service discovery config
mkdir -p /srv/service-discovery/
chmod a+rwx /srv/service-discovery/
# Write Prometheus config
cat <<EOCF >/srv/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'exoscale'
file_sd_configs:
- files:
- /srv/service-discovery/config.json
refresh_interval: 10s
EOCF
# Create the network
docker network create monitoring
# Run service discovery agent
docker run \
-d \
--name sd \
--network monitoring \
-v /srv/service-discovery:/var/run/prometheus-sd-exoscale-instance-pools \
janoszen/prometheus-sd-exoscale-instance-pools:1.0.0 \
--exoscale-api-key ${exoscale_key} \
--exoscale-api-secret ${exoscale_secret} \
--exoscale-zone-id ${exoscale_zone_id} \
--instance-pool-id ${instance_pool_id}
# Run Prometheus
docker run -d \
-p 9090:9090 \
--name prometheus \
--network monitoring \
-v /srv/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /srv/service-discovery/:/srv/service-discovery/ \
prom/prometheus