mda590
4/21/2019 - 4:05 PM

Looks in a directory and echos out a YAML formatted string containing a list of rules files which can be put into a Prometheus configuration

Looks in a directory and echos out a YAML formatted string containing a list of rules files which can be put into a Prometheus configuration file

#!/bin/bash

FILES=$(ls -1)
BASE_RULES_PATH="/etc/rules"
FILE_LIST=""

for file in $FILES; do
  if [[ $file =~ .*.yaml|.*.yml ]]; then
    FILE_LIST+="    - $BASE_RULES_PATH/$file\n"
  fi
done

echo -e "$FILE_LIST"