Create password for prometheus authentication

To create the password hash that can be used in basic authentication with prometheus you can can use the following:

htpasswd -nBC 10 ""  t -d ':\n'


10 is the bcrypt cost. Usually, the cost used should be between 10 and 12, with current computing power. Increasing this number will likely increase the security of the password at the expense of compute resources.

This can be then used in the configuration file like:

tls_server_config:
  cert_file: prometheus.crt
  key_file: prometheus.key
basic_auth_users:
  user: hhshdhdhdhhdhashedpassword

Note: Taken from the book ‘Prometheus Up & Running second edition’ by Julien Pivotto, Brian Brazil from Oreilly