From eb5f66ad9ee3902cc138bf6b93ab27b0665e050e Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 9 Oct 2018 22:53:19 +0300 Subject: [PATCH 1/4] coredns plugin -- Increase querylog given out to web UI from 1000 to 5000. --- client/src/components/Logs/index.js | 2 +- coredns_plugin/querylog.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index 59a3ca16..ad9a405d 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -255,7 +255,7 @@ class Logs extends Component { const { queryLogEnabled } = dashboard; return ( - +
{this.renderButtons(queryLogEnabled)}
diff --git a/coredns_plugin/querylog.go b/coredns_plugin/querylog.go index ecf9185b..2ca0eb2d 100644 --- a/coredns_plugin/querylog.go +++ b/coredns_plugin/querylog.go @@ -24,7 +24,7 @@ const ( queryLogTimeLimit = time.Hour * 24 // how far in the past we care about querylogs queryLogRotationPeriod = time.Hour * 24 // rotate the log every 24 hours queryLogFileName = "querylog.json" // .gz added during compression - queryLogCacheSize = 1000 // maximum API response for /querylog + queryLogSize = 5000 // maximum API response for /querylog queryLogCacheTime = time.Minute // if requested more often than this, give out cached response queryLogTopSize = 500 // Keep in memory only top N values queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed @@ -116,8 +116,8 @@ func handleQueryLog(w http.ResponseWriter, r *http.Request) { values = logBuffer logBufferLock.RUnlock() - if len(values) < queryLogCacheSize { - values = appendFromLogFile(values, queryLogCacheSize, queryLogTimeLimit) + if len(values) < queryLogSize { + values = appendFromLogFile(values, queryLogSize, queryLogTimeLimit) } queryLogLock.Lock() queryLogCache = values From 9b489c8ddb8802f553e0139852f919f7ff5d974d Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 10 Oct 2018 00:05:14 +0300 Subject: [PATCH 2/4] Makefile -- Fix bug introduced by 93c451cb0c5d7b2af900453e05674fdc65db058a make would always run webpack, even if output was generated already. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e2ba977f..7117ed63 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH) mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path))) GOPATH := $(mkfile_dir)/build/gopath -STATIC := build/static/bundle.css build/static/bundle.js build/static/index.html +STATIC := build/static/index.html .PHONY: all build clean all: build From 4984c55bceb5078f392798e64b4ad414581e1fee Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 10 Oct 2018 00:04:41 +0300 Subject: [PATCH 3/4] Update .gitignore to ignore non-gzipped querylog --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 53e4b4dd..304e52f6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,5 @@ /coredns /Corefile /dnsfilter.txt -/querylog.json.gz -/querylog.json.gz.1 +/querylog.json +/querylog.json.1 From 5533b434dac98ba610028ca98327992d18078da0 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 10 Oct 2018 00:23:15 +0300 Subject: [PATCH 4/4] coredns plugin -- give out to browser last entries from querylog file, not first --- coredns_plugin/querylog_file.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/coredns_plugin/querylog_file.go b/coredns_plugin/querylog_file.go index 72cd4d32..932dc105 100644 --- a/coredns_plugin/querylog_file.go +++ b/coredns_plugin/querylog_file.go @@ -250,9 +250,6 @@ func appendFromLogFile(values []logEntry, maxLen int, timeWindow time.Duration) } needMore := func() bool { - if len(a) >= maxLen { - return false - } return true }