#!/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