ansible-role-prometheus/files/generate-config.sh
2021-08-14 16:21:14 +01:00

21 lines
458 B
Bash

#!/bin/bash
set -euo pipefail
tmpfile=`mktemp`
(
cat /etc/prometheus/conf.d/*.conf
echo "alerting:"
echo " alertmanagers:"
(cat /etc/prometheus/conf.d/alerting/*.conf 2> /dev/null | sed "s/^/ /") || echo ""
echo "scrape_configs:"
cat /etc/prometheus/conf.d/scrape_configs/*.conf
) > $tmpfile
chmod 0644 $tmpfile
mv $tmpfile /etc/prometheus/prometheus.yml
/usr/bin/systemctl reload prometheus
/usr/bin/systemctl reload prometheus-alertmanager || true