6
0
Fork 0

Add minimal types for prometheus and its blackbox exporter

This commit is contained in:
Timothée Floure 2020-12-01 13:18:27 +01:00
parent 70a42c5dab
commit 25a6edfe75
Signed by: tfloure
GPG Key ID: 4502C902C00A1E12
7 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#!/bin/sh
cat << EOF
global:
scrape_interval: ${GLOBAL_SCRAPE_INTERVAL:?} # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: ${GLOBAL_EVALUATION_INTERVAL:?} # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels: $EXTERNAL_LABELS
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: [ $ALERTMANAGER_ADDR ]
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files: [ $RULE_FILES ]
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
EOF
for config in $SCRAPE_JOB_CONFIGS; do
sed 's/^/ /' < "$config"
done

View File

@ -0,0 +1,42 @@
#!/bin/sh
os="$(cat "${__global:?}/explorer/os")"
case "$os" in
alpine|debian|ubuntu)
__package prometheus
;;
*)
echo "This type does not supper $os. Exiting." >&2
exit 1
;;
esac
export GLOBAL_SCRAPE_INTERVAL=60s
export GLOBAL_EVALUATION_INTERVAL=60s
export EXTERNAL_LABELS=
if [ -f "${__object:?}/parameter/alertmanager-addr" ]; then
ALERTMANAGER_ADDR=$(cat "${__object:?}/parameter/alertmanager-addr")
fi
export ALERTMANAGER_ADDR
if [ -f "${__object:?}/parameter/rule-files" ]; then
RULE_FILES=$(cat "${__object:?}/parameter/rule-files")
fi
export RULE_FILES
SCRAPE_JOB_CONFIGS=$(cat "${__object:?}/parameter/scrape-job-config")
export SCRAPE_JOB_CONFIGS
# Generate and deploy configuration
mkdir -p "${__object:?}/files"
"${__type:?}/files/prometheus.yml.sh" > "${__object:?}/files/prometheus.yml"
require="__package/prometheus" __file /etc/prometheus/prometheus.yml \
--source "${__object:?}/files/prometheus.yml" \
--mode 0644 \
--onchange "service prometheus restart"
require="__package/prometheus" __start_on_boot prometheus
require="__package/prometheus" __service prometheus --action start

View File

@ -0,0 +1,2 @@
alertmanager-addr
rule_files

View File

@ -0,0 +1 @@
scrape-job-config

View File

View File

@ -0,0 +1,19 @@
#!/bin/sh
os="$(cat "${__global:?}/explorer/os")"
case "$os" in
alpine)
__package blackbox_exporter
require="__package/blackbox_exporter" __start_on_boot \
blackbox_exporter
require="__package/blackbox_exporter" __service \
blackbox_exporter --action start
;;
debian|ubuntu)
__package prometheus-blackbox-exporter
;;
*)
echo "This type does not supper $os. Exiting." >&2
exit 1
;;
esac