coredns plugin -- Calculate top for domains, clients and blocked both from querylog and running requests.

This moves the functionality from frontend to coredns plugin.
This commit is contained in:
Eugene Bujak
2018-10-07 23:24:04 +03:00
parent 3b1faa1365
commit a2434d4574
6 changed files with 394 additions and 183 deletions

View File

@@ -147,9 +147,6 @@ func setupPlugin(c *caddy.Controller) (*plug, error) {
p.settings.BlockedTTL = uint32(blockttl)
case "querylog":
p.settings.QueryLogEnabled = true
onceQueryLog.Do(func() {
go startQueryLogServer() // TODO: how to handle errors?
})
}
}
}
@@ -186,7 +183,19 @@ func setupPlugin(c *caddy.Controller) (*plug, error) {
}
}
var err error
log.Printf("Loading top from querylog")
err := loadTopFromFiles()
if err != nil {
log.Printf("Failed to load top from querylog: %s", err)
return nil, err
}
if p.settings.QueryLogEnabled {
onceQueryLog.Do(func() {
go startQueryLogServer() // TODO: how to handle errors?
})
}
p.upstream, err = upstream.New(nil)
if err != nil {
return nil, err