add command to create prometheus scrape config
This commit is contained in:
parent
83eb9c47c2
commit
d31d56ed03
24
abra.sh
24
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
|
||||
}
|
Loading…
Reference in New Issue