diff --git a/abra.sh b/abra.sh index 58c463e..f17e47b 100644 --- a/abra.sh +++ b/abra.sh @@ -9,3 +9,27 @@ export PROMTAIL_YML_VERSION=v1 export LOKI_YML_VERSION=v1 export PROMETHEUS_YML_VERSION=v1 export ALERTMANAGER_CONFIG_VERSION=v1 + +# creates a default prometheus scrape config for a given node +add_node(){ + name=$1 + add_domain "$name" "$name:8082/metrics" + add_domain "$name" "node.monitoring.$name" + add_domain "$name" "cadvisor.monitoring.$name" + cat "/prometheus/scrape_configs/$name.yml" +} + +# adds a domain to a scrape config or creates a new one +add_domain(){ + name=$1 + domain=$2 + if [ ! -d "/prometheus/scrape_configs/" ]; then + mkdir -p /prometheus/scrape_configs/ + fi + cd /prometheus/scrape_configs/ || exit 1 + if [ ! -f "$name.yml" ]; then + echo -e "- targets:\n - '$domain'" > "$name.yml" + else + echo " - '$domain'" >> "$name.yml" + fi +} \ No newline at end of file