2016-04-03 09:15:55 +01:00
# prometheus
2018-01-04 12:53:07 +00:00
## Name
2016-04-03 09:15:55 +01:00
2018-01-04 12:53:07 +00:00
*prometheus* - enables [Prometheus ](https://prometheus.io/ ) metrics.
## Description
With *prometheus* you export metrics from CoreDNS and any plugin that has them.
2017-07-24 08:24:53 -07:00
The default location for the metrics is `localhost:9153` . The metrics path is fixed to `/metrics` .
2022-02-09 13:52:18 -05:00
In addition to the default Go metrics exported by the [Prometheus Go client ](https://prometheus.io/docs/guides/go-application/ ),
the following metrics are exported:
2016-04-03 09:15:55 +01:00
2018-01-23 21:10:55 +01:00
* `coredns_build_info{version, revision, goversion}` - info about CoreDNS itself.
2020-03-26 09:17:33 +01:00
* `coredns_panics_total{}` - total number of panics.
2022-09-08 14:56:27 -04:00
* `coredns_dns_requests_total{server, zone, view, proto, family, type}` - total query count.
* `coredns_dns_request_duration_seconds{server, zone, view, type}` - duration to process each query.
* `coredns_dns_request_size_bytes{server, zone, view, proto}` - size of the request in bytes.
* `coredns_dns_do_requests_total{server, view, zone}` - queries that have the DO bit set
* `coredns_dns_response_size_bytes{server, zone, view, proto}` - response size in bytes.
* `coredns_dns_responses_total{server, zone, view, rcode, plugin}` - response per zone, rcode and plugin.
2022-02-17 14:37:40 +01:00
* `coredns_dns_https_responses_total{server, status}` - responses per server and http status code.
2022-09-14 20:45:45 +02:00
* `coredns_plugin_enabled{server, zone, view, name}` - indicates whether a plugin is enabled on per server, zone and view basis.
2016-07-04 06:08:45 -04:00
2022-02-17 14:37:40 +01:00
Almost each counter has a label `zone` which is the zonename used for the request/response.
2016-07-04 06:08:45 -04:00
Extra labels used are:
2018-04-18 09:42:20 +01:00
* `server` is 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 is `dns://:53` . If you are using the *bind* plugin an IP address is included, e.g.: `dns://127.0.0.53:53` .
2016-07-04 06:08:45 -04:00
* `proto` which 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)).
2016-08-22 14:29:50 -07:00
* `type` which holds the query type. It holds most common types (A, AAAA, MX, SOA, CNAME, PTR, TXT,
2021-10-28 10:50:23 +02:00
NS, SRV, DS, DNSKEY, RRSIG, NSEC, NSEC3, HTTPS, IXFR, AXFR and ANY) and "other" which lumps together all
2016-07-04 06:08:45 -04:00
other types.
2022-02-17 14:37:40 +01:00
* `status` which holds the https status code. Possible values are:
* 200 - request is processed,
* 404 - request has been rejected on validation,
* 400 - request to dns message conversion failed,
2022-02-22 10:28:07 +00:00
* 500 - processing ended up with no response.
Metrics: expand coredns_dns_responses_total with plugin label (#4914)
* Metrics: expand coredns_dns_responses_total with plugin label
This adds (somewhat hacky?) code to add a plugin label to the
coredns_dns_responses_total metric. It's completely obvlious to the
plugin as we just check who called the *recorder.WriteMsg method. We use
runtime.Caller( 1 2 3) to get multiple levels of callers, this should be
deep enough, but it depends on the dns.ResponseWriter wrapping that's
occuring.
README.md of metrics updates and test added in test/metrics_test.go to
check for the label being set.
I went through the plugin to see what metrics could be removed, but
actually didn't find any, the plugin push out metrics that make sense.
Due to the path fiddling to figure out the plugin name I doubt this
works (out-of-the-box) for external plugins, but I haven't tested that.
Signed-off-by: Miek Gieben <miek@miek.nl>
* better comment
Signed-off-by: Miek Gieben <miek@miek.nl>
* Metrics: expand coredns_dns_responses_total with plugin label
This adds (somewhat hacky?) code to add a plugin label to the
coredns_dns_responses_total metric. It's completely obvlious to the
plugin as we just check who called the *recorder.WriteMsg method. We use
runtime.Caller( 1 2 3) to get multiple levels of callers, this should be
deep enough, but it depends on the dns.ResponseWriter wrapping that's
occuring.
README.md of metrics updates and test added in test/metrics_test.go to
check for the label being set.
I went through the plugin to see what metrics could be removed, but
actually didn't find any, the plugin push out metrics that make sense.
Due to the path fiddling to figure out the plugin name I doubt this
works (out-of-the-box) for external plugins, but I haven't tested that.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Update core/dnsserver/server.go
Co-authored-by: dilyevsky <ilyevsky@gmail.com>
* Use [3]string
Signed-off-by: Miek Gieben <miek@miek.nl>
* imports
Signed-off-by: Miek Gieben <miek@miek.nl>
* remove dnstest changes
Signed-off-by: Miek Gieben <miek@miek.nl>
* revert
Signed-off-by: Miek Gieben <miek@miek.nl>
* Add some sleeps to make it less flaky
Signed-off-by: Miek Gieben <miek@miek.nl>
* Revert "Add some sleeps to make it less flaky"
This reverts commit b5c6655196e3ad570555f086832ceb1f48f6f2d5.
* Remove forward when not needed
Signed-off-by: Miek Gieben <miek@miek.nl>
* remove newline
Signed-off-by: Miek Gieben <miek@miek.nl>
Co-authored-by: dilyevsky <ilyevsky@gmail.com>
2021-11-12 16:07:05 +00:00
* the `plugin` label holds the name of the plugin that made the write to the client. If the server
did the write (on error for instance), the value is empty.
2016-04-03 09:15:55 +01:00
2017-09-14 09:36:06 +01:00
If monitoring is enabled, queries that do not enter the plugin chain are exported under the fake
2016-10-26 10:01:52 +01:00
name "dropped" (without a closing dot - this is never a valid domain name).
2016-04-03 09:15:55 +01:00
2022-02-09 13:52:18 -05:00
Other plugins may export additional stats when the _prometheus_ plugin is enabled. Those stats are documented in each
plugin's README.
2018-03-02 17:16:25 -08:00
This plugin can only be used once per Server Block.
2016-04-03 09:15:55 +01:00
## Syntax
~~~
2016-10-10 20:13:22 +01:00
prometheus [ADDRESS]
2016-04-03 09:15:55 +01:00
~~~
For each zone that you want to see metrics for.
2019-02-12 18:54:54 +01:00
It optionally takes a bind address to which the metrics are exported; the default
listens on `localhost:9153` . The metrics path is fixed to `/metrics` .
2016-04-03 09:15:55 +01:00
## Examples
2016-10-26 10:01:52 +01:00
2019-02-12 18:54:54 +01:00
Use an alternative listening address:
2016-10-26 10:01:52 +01:00
2017-09-15 09:56:05 +01:00
~~~ corefile
. {
prometheus localhost:9253
}
2016-10-26 10:01:52 +01:00
~~~
2017-02-21 19:34:40 +00:00
2018-08-14 17:55:55 +02:00
Or via an environment variable (this is supported throughout the Corefile): `export PORT=9253` , and
2017-10-18 17:20:27 +01:00
then:
~~~ corefile
. {
prometheus localhost:{$PORT}
}
~~~
2018-01-10 11:45:12 +00:00
## Bugs
2017-02-21 19:34:40 +00:00
2018-07-09 13:08:02 +01:00
When reloading, the Prometheus handler is stopped before the new server instance is started.
If that new server fails to start, then the initial server instance is still available and DNS queries still served,
but Prometheus handler stays down.
2018-05-09 10:09:06 -04:00
Prometheus will not reply HTTP request until a successful reload or a complete restart of CoreDNS.
2019-03-23 10:43:15 +01:00
Only the plugins that register as Handler are visible in `coredns_plugin_enabled{server, zone, name}` . As of today the plugins reload and bind will not be reported.