401 on PowerDNS metrics endpoint

103 views Asked by At

I have a PowerDNS Authoritative Server 4.8.3 instance deployed in docker with (among others) the following configuration:

- PDNS_api=yes       
- PDNS_api_key=<api_key>
- PDNS_webserver=yes
- PDNS_webserver-allow-from=127.0.0.1,10.0.0.0/8,172.0.0.0/8,192.168.0.0/16
- PDNS_webserver_address=0.0.0.0
- PDNS_webserver_password=<password>

but I can't get access to the /metrics endpoint with Prometheus. I always get an HTTP 401 whatever configuration I try (with credentials and/or basic auth).

I get the same thing when trying directly with curl

curl -v -H 'X-API-Key: <api_key>' -u":<password>" http://pdns:8081/metrics
curl -v -u":<password>" http://pdns:8081/metrics
curl -v -H 'X-API-Key: <api_key>' http://pdns:8081/metrics`

But i'v always the same error :

* Trying 192.168.96.9:8081...

* Connected to pdns (192.168.96.9) port 8081 (#0)

> GET /metrics HTTP/1.1
> Host: pdns:8081
> User-Agent: curl/7.88.1
> Accept: */*
> X-API-Key: <api_key>

< HTTP/1.1 401 Unauthorized
< Connection: close
< Content-Length: 12
< Content-Type: text/plain; charset=utf-8
< Www-Authenticate: Basic realm="PowerDNS"`

What am I missing?

Thanks !

1

There are 1 answers

0
Gizex On BEST ANSWER

use "#" as user

curl -i 10.0.0.251:8081/metrics -u=#:pass



HTTP/1.1 200 OK
Connection: close
Content-Length: 15050
Content-Type: text/plain

# HELP pdns_auth_backend_queries Number of queries sent to the backend(s)
# TYPE pdns_auth_backend_queries counter
pdns_auth_backend_queries 28
# HELP pdns_auth_corrupt_packets Number of corrupt packets received
# TYPE pdns_auth_corrupt_packets counter
pdns_auth_corrupt_packets 0
# HELP pdns_auth_deferred_cache_inserts Amount of cache inserts that were deferred because of maintenance
# TYPE pdns_auth_deferred_cache_inserts counter
pdns_auth_deferred_cache_inserts 0
# HELP pdns_auth_deferred_cache_lookup Amount of cache lookups that were deferred because of maintenance
# TYPE pdns_auth_deferred_cache_lookup counter
pdns_auth_deferred_cache_lookup 0

and for prometheus

-   job_name: powerdns
    static_configs:
    -   targets:
        - 10.0.0.251:8081
    basic_auth:
        username: '#'
        password: 'pass'