Skip to content

Commit f0c7c77

Browse files
authored
Merge pull request gcgarner#78 from pelted/master
Adds Prometheus and add-ons containers
2 parents 4e83884 + e07ff4b commit f0c7c77

File tree

7 files changed

+80
-0
lines changed

7 files changed

+80
-0
lines changed

.templates/prometheus/build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
DOCKER_COMPOSE_PATH=./.tmp/docker-compose.tmp.yml
4+
TEMPLATE_PATH=./.templates/prometheus
5+
6+
if [[ ! -f $DOCKER_COMPOSE_PATH ]]; then
7+
echo "[Prometheus] Warning: $DOCKER_COMPOSE_PATH does not exist."
8+
fi
9+
10+
# Configure Prometheus Add-ons
11+
12+
option_selection=$(whiptail --title "Select Prometheus Options" --checklist --separate-output \
13+
"Use the [SPACEBAR] to select add-on containers from the list below." 20 78 12 -- \
14+
"node-exporter" "monitor this computer " "ON" \
15+
"cadvisor-arm" "monitor full container stack " "ON" \
16+
3>&1 1>&2 2>&3)
17+
18+
mapfile -t selected_options <<< "$option_selection"
19+
20+
# (cat $TEMPLATE_PATH/service.yml; echo) >> $DOCKER_COMPOSE_PATH
21+
22+
for option in "${selected_options[@]}"; do
23+
# insert add-on service
24+
(cat $TEMPLATE_PATH/service_${option}.yml; echo) >> $DOCKER_COMPOSE_PATH
25+
26+
# include add-on in depends_on
27+
sed -i.bak -e "/depends_on:/a\\
28+
\\ \\ \\ \\ \\ \\ - ${option}" $DOCKER_COMPOSE_PATH
29+
done
30+
31+
# clean up
32+
rm ${DOCKER_COMPOSE_PATH}.bak

.templates/prometheus/config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
global:
2+
scrape_interval: 10s
3+
evaluation_interval: 10s
4+
5+
# scrape_configs:
6+
# - job_name: iotstack
7+
# static_configs:
8+
# - targets:
9+
# - cadvisor:8080
10+
# - node-exporter:9100

.templates/prometheus/prometheus.env

Whitespace-only changes.

.templates/prometheus/service.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
prometheus:
2+
container_name: prometheus
3+
image: prom/prometheus:latest
4+
restart: unless-stopped
5+
user: "0"
6+
ports:
7+
- 9090:9090
8+
env_file:
9+
- ./services/prometheus/prometheus.env
10+
depends_on:
11+
volumes:
12+
- ./services/prometheus/config.yml:/etc/prometheus/config.yml
13+
- ./volumes/prometheus/data:/data
14+
command:
15+
- '--config.file=/etc/prometheus/config.yml'
16+
- '--storage.tsdb.path=/data'
17+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cadvisor-arm:
2+
container_name: cadvisor
3+
image: budry/cadvisor-arm:latest
4+
restart: unless-stopped
5+
user: "0"
6+
privileged: true
7+
ports:
8+
- 8080:8080
9+
volumes:
10+
- /:/rootfs:ro
11+
- /var/run:/var/run:rw
12+
- /sys:/sys:ro
13+
- /var/lib/docker/:/var/lib/docker:ro
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node-exporter:
2+
image: prom/node-exporter:latest
3+
container_name: node_exporter
4+
restart: unless-stopped
5+
expose:
6+
- 9100

menu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ declare -A cont_array=(
2525
[transmission]="transmission"
2626
[grafana]="Grafana"
2727
[mosquitto]="Eclipse-Mosquitto"
28+
[prometheus]="Prometheus"
2829
[postgres]="Postgres"
2930
[timescaledb]="Timescaledb"
3031
[mariadb]="MariaDB (MySQL fork)"
@@ -61,6 +62,7 @@ declare -a armhf_keys=(
6162
"grafana"
6263
"mosquitto"
6364
"telegraf"
65+
"prometheus"
6466
"mariadb"
6567
"postgres"
6668
"timescaledb"

0 commit comments

Comments
 (0)