Monitoring Prometheus itself with basic auth

320 views
Skip to first unread message

Hank Huang

unread,
May 20, 2022, 3:51:00 AM5/20/22
to Prometheus Users
Hi there!

I followed the doc to configure Prometheus to monitor itself, and it works fine.
but then I added basic auth, and the metrics stop updating, and querying "up" returns 0.
at first, I suspected prometheus will also requires basic auth to scrape itself, so I added the same basic auth username/password to config file, but still no luck.

config file (prometheus.yml):
Screenshot 2022-05-20 134752.png

web config file (web.yml):
Screenshot 2022-05-20 131614.png

and I am launching Prometheus with the two config files (using prometheus 2.35.0 on windows):
.\prometheus.exe --config.file=prometheus.yml --web.config.file=web.yml

"up" returns 0:
Screenshot 2022-05-20 131948.png

Any insight is appreciated.


Brian Candler

unread,
May 20, 2022, 8:03:51 AM5/20/22
to Prometheus Users
You're giving the wrong password in the scrape job.

basic_auth:
  username: admin
  password: <PUT-THE-REAL-PASSWORD-HERE>

The value starting $2b$... is a *hash* of the password. This is fine to go in web.yml, since Prometheus will take the client-supplied password, hash it, and compare it with the stored hash.

But for the client which is making the connection, it must supply the actual password.
Reply all
Reply to author
Forward
0 new messages