Add minimal types for prometheus and its blackbox exporter
This commit is contained in:
parent
70a42c5dab
commit
25a6edfe75
7 changed files with 93 additions and 0 deletions
29
type/__prometheus/files/prometheus.yml.sh
Executable file
29
type/__prometheus/files/prometheus.yml.sh
Executable 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
|
42
type/__prometheus/manifest
Normal file
42
type/__prometheus/manifest
Normal 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
|
2
type/__prometheus/parameter/optional
Normal file
2
type/__prometheus/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
alertmanager-addr
|
||||
rule_files
|
1
type/__prometheus/parameter/optional_multiple
Normal file
1
type/__prometheus/parameter/optional_multiple
Normal file
|
@ -0,0 +1 @@
|
|||
scrape-job-config
|
0
type/__prometheus/singleton
Normal file
0
type/__prometheus/singleton
Normal file
19
type/__prometheus_blackbox_exporter/manifest
Normal file
19
type/__prometheus_blackbox_exporter/manifest
Normal 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
|
0
type/__prometheus_blackbox_exporter/singleton
Normal file
0
type/__prometheus_blackbox_exporter/singleton
Normal file
Reference in a new issue