middleware/metrics: cleanup (#355)

* middleware/metrics: add more metrics

middleware/cache:
Add metrics for number of elements in the cache. Also export the total
size. Update README to detail the new metrics.

middleware/metrics

Move metrics into subpackage called "vars". This breaks the import
cycle and is cleaner. This allows vars.Report to be used in the
the dnsserver to log refused queries.

middleware/metrics: tests

Add tests to the metrics framework. The metrics/test subpackage allows
scraping of the local server. Do a few test scrape of the metrics that
are defined in the metrics middleware.

This also allows metrics integration tests to check if the caching and
dnssec middleware export their metrics correctly.

* update README

* typos

* fix tests
This commit is contained in:
Miek Gieben
2016-10-26 10:01:52 +01:00
committed by GitHub
parent 6d9d60081d
commit 219bfd0493
39 changed files with 828 additions and 259 deletions

View File

@@ -35,24 +35,24 @@ There is a third category (`error`) but those responses are never cached.
The minimum TTL allowed on resource records is 5 seconds.
If monitoring is enabled (via the *prometheus* directive) then the following extra metrics are added:
## Metrics
* coredns_cache_hit_count_total, and
* coredns_cache_miss_count_total
If monitoring is enabled (via the *prometheus* directive) then the following metrics are exported:
They both work on a per-zone basis and just count the hit and miss counts for each query.
* coredns_cache_size_guage{type} - total elements in the case, type is either "denial" or "success".
* coredns_cache_capacity_guage{type} - total capacity of the cache, type is either "denial" or "success".
## Examples
Enable caching for all zones, but cap everything to a TTL of 10 seconds:
~~~
cache 10
~~~
Enable caching for all zones, but cap everything to a TTL of 10 seconds.
Proxy to Google Public DNS and only cache responses for example.org (or below).
~~~
proxy . 8.8.8.8:53
cache example.org
~~~
Proxy to Google Public DNS and only cache responses for example.org (or below).