* reload: use OnRestart
Close the listener on OnRestart for health and metrics so the default
setup function can setup the listener when the plugin is "starting up".
Lightly test with some SIGUSR1-ing. Also checked the reload plugin with
this, seems fine:
.com.:1043
.:1043
2018/04/20 15:01:25 [INFO] CoreDNS-1.1.1
2018/04/20 15:01:25 [INFO] linux/amd64, go1.10,
CoreDNS-1.1.1
linux/amd64, go1.10,
2018/04/20 15:01:25 [INFO] Running configuration MD5 = aa8b3f03946fb60546ca1f725d482714
2018/04/20 15:02:01 [INFO] Reloading
2018/04/20 15:02:01 [INFO] Running configuration MD5 = b34a96d99e01db4015a892212560155f
2018/04/20 15:02:01 [INFO] Reloading complete
^C2018/04/20 15:02:06 [INFO] SIGINT: Shutting down
With this corefile:
.com {
proxy . 127.0.0.1:53
prometheus :9054
whoami
reload
}
. {
proxy . 127.0.0.1:53
prometheus :9054
whoami
reload
}
The prometheus port was 9053, changed that to 54 so reload would pick it
up.
From a cursory look it seems this also fixes:
Fixes #1604 #1618 #1686 #1492
* At least make it test
* Use onfinalshutdown
* reload: add reload test
This test #1604 adn right now fails.
* Address review comments
* Add bug section explaining things a bit
* compile tests
* Fix tests
* fixes
* slightly less crazy
* try to make prometheus setup less confusing
* Use ephermal port for test
* Don't use the listener
* These are shared between goroutines, just use the boolean in the main
structure.
* Fix text in the reload README,
* Set addr to TODO once stopping it
* Morph fturb's comment into test, to test reload and scrape health and
metric endpoint
prometheus
Name
prometheus - enables Prometheus metrics.
Description
With prometheus you export metrics from CoreDNS and any plugin that has them.
The default location for the metrics is localhost:9153. The metrics path is fixed to /metrics.
The following metrics are exported:
coredns_build_info{version, revision, goversion}- info about CoreDNS itself.coredns_dns_request_count_total{server, zone, proto, family}- total query count.coredns_dns_request_duration_seconds{server, zone}- duration to process each query.coredns_dns_request_size_bytes{server, zone, proto}- size of the request in bytes.coredns_dns_request_do_count_total{server, zone}- queries that have the DO bit setcoredns_dns_request_type_count_total{server, zone, type}- counter of queries per zone and type.coredns_dns_response_size_bytes{server, zone, proto}- response size in bytes.coredns_dns_response_rcode_count_total{server, zone, rcode}- response per zone and rcode.
Each counter has a label zone which is the zonename used for the request/response.
Extra labels used are:
serveris identifying the server responsible for the request. This is a string formatted as the server's listening address:<scheme>://[<bind>]:<port>. I.e. for a "normal" DNS server this isdns://:53. If you are using the bind plugin an IP address is included, e.g.:dns://127.0.0.53:53.protowhich holds the transport of the response ("udp" or "tcp")- The address family (
family) of the transport (1 = IP (IP version 4), 2 = IP6 (IP version 6)). typewhich holds the query type. It holds most common types (A, AAAA, MX, SOA, CNAME, PTR, TXT, NS, SRV, DS, DNSKEY, RRSIG, NSEC, NSEC3, IXFR, AXFR and ANY) and "other" which lumps together all other types.- The
response_rcode_count_totalhas an extra labelrcodewhich holds the rcode of the response.
If monitoring is enabled, queries that do not enter the plugin chain are exported under the fake name "dropped" (without a closing dot - this is never a valid domain name).
This plugin can only be used once per Server Block.
Syntax
prometheus [ADDRESS]
For each zone that you want to see metrics for.
It optionally takes an address to which the metrics are exported; the default
is localhost:9153. The metrics path is fixed to /metrics.
Examples
Use an alternative address:
. {
prometheus localhost:9253
}
Or via an enviroment variable (this is supported throughout the Corefile): export PORT=9253, and
then:
. {
prometheus localhost:{$PORT}
}
Bugs
When reloading, we keep the handler running, meaning that any changes to the handler's address aren't picked up. You'll need to restart CoreDNS for that to happen.