Repository: nextdns/nextdns

Issue #154: Request: add ability to get cache performance metrics
Created: 2020-04-15T22:56:40Z
Would be nice to get cache performance metrics.  Hits, misses, # of cache entries, etc.
Also option to allow these cache metrics to be dumped to the log on a interval like hourly would be excellent.

Duplicate issue #173: Feature request: Provide statistics
Created: 2020-04-20T18:49:46Z
At least basic statistics would be of great help, invoked with something like nextdns stats.
It should probably mimic what unbound outputs (with the option to have extended or not, cumulative or not), which would allow to take advantage of existing tooling around it for free (eg. munin charts and other monitoring tools in particular).
      statistics-cumulative: <yes or no>
              If  enabled,  statistics  are cumulative since starting unbound,
              without clearing the statistics counters after logging the  sta-
              tistics. Default is no.

       extended-statistics: <yes or no>
              If  enabled,  extended  statistics are printed from unbound-con-
              trol(8).  Default is off, because keeping track of more  statis-
              tics takes time.  The counters are listed in unbound-control(8).

Example output (probably not everything is implementable easily, but starting with the basics like cache hits and total queries at least):
thread0.num.queries=20550
thread0.num.queries_ip_ratelimited=0
thread0.num.cachehits=18226
thread0.num.cachemiss=2324
thread0.num.prefetch=12179
thread0.num.zero_ttl=12510
thread0.num.recursivereplies=2324
thread0.requestlist.avg=1.62815
thread0.requestlist.max=63
thread0.requestlist.overwritten=0
thread0.requestlist.exceeded=0
thread0.requestlist.current.all=0
thread0.requestlist.current.user=0
thread0.recursion.time.avg=0.176575
thread0.recursion.time.median=0.0931082
thread0.tcpusage=0
total.num.queries=20550
total.num.queries_ip_ratelimited=0
total.num.cachehits=18226
total.num.cachemiss=2324
total.num.prefetch=12179
total.num.zero_ttl=12510
total.num.recursivereplies=2324
total.requestlist.avg=1.62815
total.requestlist.max=63
total.requestlist.overwritten=0
total.requestlist.exceeded=0
total.requestlist.current.all=0
total.requestlist.current.user=0
total.recursion.time.avg=0.176575
total.recursion.time.median=0.0931082
total.tcpusage=0
time.now=1569781900.158381
time.up=139650.901667
time.elapsed=139650.901667
mem.cache.rrset=4689536
mem.cache.message=1606897
mem.mod.iterator=16588
mem.mod.validator=719967
mem.mod.respip=0
mem.mod.subnet=74488
histogram.000000.000000.to.000000.000001=175
histogram.000000.000001.to.000000.000002=0
histogram.000000.000002.to.000000.000004=0
histogram.000000.000004.to.000000.000008=0
histogram.000000.000008.to.000000.000016=0
histogram.000000.000016.to.000000.000032=0
histogram.000000.000032.to.000000.000064=0
histogram.000000.000064.to.000000.000128=0
histogram.000000.000128.to.000000.000256=0
histogram.000000.000256.to.000000.000512=0
histogram.000000.000512.to.000000.001024=0
histogram.000000.001024.to.000000.002048=0
histogram.000000.002048.to.000000.004096=2
histogram.000000.004096.to.000000.008192=3
histogram.000000.008192.to.000000.016384=150
histogram.000000.016384.to.000000.032768=319
histogram.000000.032768.to.000000.065536=314
histogram.000000.065536.to.000000.131072=473
histogram.000000.131072.to.000000.262144=454
histogram.000000.262144.to.000000.524288=292
histogram.000000.524288.to.000001.000000=100
histogram.000001.000000.to.000002.000000=30
histogram.000002.000000.to.000004.000000=10
histogram.000004.000000.to.000008.000000=2
histogram.000008.000000.to.000016.000000=0
histogram.000016.000000.to.000032.000000=0
histogram.000032.000000.to.000064.000000=0
histogram.000064.000000.to.000128.000000=0
histogram.000128.000000.to.000256.000000=0
histogram.000256.000000.to.000512.000000=0
histogram.000512.000000.to.001024.000000=0
histogram.001024.000000.to.002048.000000=0
histogram.002048.000000.to.004096.000000=0
histogram.004096.000000.to.008192.000000=0
histogram.008192.000000.to.016384.000000=0
histogram.016384.000000.to.032768.000000=0
histogram.032768.000000.to.065536.000000=0
histogram.065536.000000.to.131072.000000=0
histogram.131072.000000.to.262144.000000=0
histogram.262144.000000.to.524288.000000=0
num.query.type.A=14911
num.query.type.PTR=3767
num.query.type.AAAA=1652
num.query.type.SRV=219
num.query.type.NAPTR=1
num.query.class.IN=20550
num.query.opcode.QUERY=20550
num.query.tcp=0
num.query.tcpout=199
num.query.ipv6=0
num.query.flags.QR=0
num.query.flags.AA=0
num.query.flags.TC=0
num.query.flags.RD=20550
num.query.flags.RA=0
num.query.flags.Z=0
num.query.flags.AD=31
num.query.flags.CD=0
num.query.edns.present=483
num.query.edns.DO=0
num.answer.rcode.NOERROR=16376
num.answer.rcode.FORMERR=0
num.answer.rcode.SERVFAIL=80
num.answer.rcode.NXDOMAIN=4094
num.answer.rcode.NOTIMPL=0
num.answer.rcode.REFUSED=0
num.answer.rcode.nodata=785
num.query.ratelimited=0
num.answer.secure=453
num.answer.bogus=0
num.rrset.bogus=0
unwanted.queries=0
unwanted.replies=1
msg.cache.count=4856
rrset.cache.count=13393
infra.cache.count=3955
key.cache.count=903

Closing comment (2020-04-20T21:20:25Z): Duplicate of #154 (though I think this one's better of course 😄 )