.net-coreiisprometheusprometheus-net

Prometheus returned error "server returned HTTP status 401 Unauthorized" for .NET core api


I have a .NET core API hosted in IIS which uses windows authentication. I'm using Prometheus to scrape metrics from this API. But I'm getting the error for the api target:

"server returned HTTP status 401 Unauthorized"

Can some help me how to configure prometheus for targets with Windows authentication?

When I tried to browse the metrics path separately, the browser is requesting for credentials and I'm able to view the metrics with my Windows authentication.


Solution

  • Looking at the documentation, Prometheus seems to support basic (user/password) and OAuth bearer token authentication only. If your API/IIS doesn't support any of those, then you either need to disable authentication for the /metrics path or maybe set up a proxy that only allows /metrics requests and does the authentication for you.