The script generates a web.yml file with a password hash using bcrypt, which is necessary to enable basic authentication for Prometheus.
The script prompts for username and password. When you enter username and password, you need waiting 10 seconds timeout for bcrypt processing.
- If there is a web.yml file, you will be prompted to either recreate it or add credentials to the end of the file.
- If there is no web.yml file, a new file will be generated.
After, you need add web.yml to Prometheus configuration:
--web.config.file=/etc/prometheus/web.yml
Prometheus documentations about basic auth: https://prometheus.io/docs/guides/basic-auth/
basic_auth_users:
test: $2y$17$Ac2deeUOLKZSP2L81awluuTAiisMp46T4NTJ0MX3tpfPXC3MUVl8G
Read the article by JFrog: Don’t let Prometheus Steal your Fire
chmod u+x generate_web_yml.sh