CZ-NIC / knot-resolver

Knot Resolver - resolve DNS names like it's 2024
https://www.knot-resolver.cz/
Other
364 stars 59 forks source link

stats api not working and kresc returns nil #61

Closed loganbest closed 5 years ago

loganbest commented 5 years ago

Hi, I stood up a new kresd server from the debian packages on deb 9. All default API endpoints (stats, metrics, etc) just return a 404. Kresc returns nil. See examples below: curl

# curl -vk https://127.0.0.1:8053/stats
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8053 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=knot-01
*  start date: Jan 16 22:42:39 2019 GMT
*  expire date: Apr 16 22:42:39 2019 GMT
*  issuer: CN=knot-01
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x5618111cea80)
> GET /stats HTTP/1.1
> Host: 127.0.0.1:8053
> User-Agent: curl/7.52.1
> Accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 404 
< 
* Curl_http_done: called premature == 0
* Connection #0 to host 127.0.0.1 left intact

kresc

# kresc /run/knot-resolver/control@1
Warning! kresc is highly experimental, use at own risk.
Please tell authors what features you expect from client utility.
kresc> modules.load('stats')
true
kresc> stats.get()
nil
kresc> 

Below is my kresd.conf

modules = {
        'policy',
        'hints > iterate',    -- Load /etc/hosts and allow custom root hints
        'stats',              -- Track internal statistics
        'predict',            -- Prefetch expiring/frequent records
        http = {
                host = 'localhost', -- Default: 'localhost'
                port = 8053,        -- Default: 8053
                geoip = '/etc/knot-resolver/GeoLite2-City.mmdb',
                endpoints = {},
        }
}
vcunat commented 5 years ago

What knot-resolver version are you using? (Package from which place.)

loganbest commented 5 years ago

From here: deb http://download.opensuse.org/repositories/home:/CZ-NIC:/knot-resolver-latest/Debian_9.0/ /

knot-resolver/unknown,now 3.2.1-1 amd64 [installed] knot-resolver-module-http/unknown,now 3.2.1-1 all [installed,automatic] libknot8/unknown,now 2.7.5-1 amd64 [installed,automatic]

pspacek commented 5 years ago

stats.get() expects name of statistics, e.g. stats.get("answer.total").

Please see also other examples in docs: https://knot-resolver.readthedocs.io/en/stable/modules.html#statistics-collector

loganbest commented 5 years ago

@pspacek Thanks, kresc works with that, however, the HTTP API does not and still returns 404 on all endpoints listed here: https://knot-resolver.readthedocs.io/en/stable/modules.html#id9

pspacek commented 5 years ago

Oh, we need to improve docs! Drop like endpoints = {}, and it should work.

loganbest commented 5 years ago

\o/ works! Thanks!

vcunat commented 5 years ago

stats.get() expects name of statistics, e.g. stats.get("answer.total").

stats.list() might be what you wanted. Docs correction before we forget: https://gitlab.labs.nic.cz/knot/knot-resolver/merge_requests/760