BIND 9: logging cache hits & misses

bindcachedomain-name-systemlogging

We want to keep track of cache usage of our BIND 9 DNS servers. Is there any way of logging cache hits and misses? We tried the BIND logging facilities (channels, categories) without luck. Also, "rndc stats" only provides partial information about cache usage. Thanks for reading.

Best Answer

You're looking for statistics, so you'll want to read what the BIND Administrator Reference Manual has to say on BIND statistics. In particular:

There are currently two user interfaces to get access to the statistics. One is in the plain text format dumped to the file specified by the statistics-file configuration option. The other is remotely accessible via a statistics channel when the statistics-channels statement is specified in the configuration file (see the section called “statistics-channels Statement Grammar”.)

Statistics can be dumped locally to the filesystem, or exposed over HTTP via the statistics channel. In the latter case you can remotely harvest the counters via a monitoring system by parsing the XML or JSON. The latter approach is definitely useful, but you'll want to make sure the HTTP socket isn't exposed to untrusted sources.

statistics-channels {
        inet 127.0.0.1 port 5302
            allow { 127.0.0.1; };
        inet 192.0.2.1 port 5302
            allow { mgt-acl; monitor-acl; };
};

In my particular case, I wrote a curl and jq based parser that takes JSON counters of interest and transforms them into the JSON format that Zenoss understands. The counters can then be graphed. Here's an example of what I'm doing with graphing query round trip time via the exposed RTT counters:

enter image description here