aboutsummaryrefslogtreecommitdiff
path: root/haminer.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-16 23:18:26 +0700
committerShulhan <ms@kilabit.info>2022-08-16 23:18:53 +0700
commit1ade2eebf51bd64c60b797c077b436b3221202bf (patch)
treecf12a3a894380af5ffec6c39a95481b35b032695 /haminer.go
parent8a6eaebb36c0761b21398e72d934c072ac67fa7f (diff)
downloadhaminer-1ade2eebf51bd64c60b797c077b436b3221202bf.tar.xz
all: remove code that sending heartbeat
Previously, if no logs received after 15 seconds (or any interval user defined in Config.ForwardInterval), the haminer process send an empty halog to forwarders (empty halog is the one that use "-" for backend, frontend, server name, and HTTP method). This cause bogus traffic and need additional filter when analyzed.
Diffstat (limited to 'haminer.go')
-rw-r--r--haminer.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/haminer.go b/haminer.go
index 10209d3..7a54e84 100644
--- a/haminer.go
+++ b/haminer.go
@@ -88,6 +88,9 @@ func (h *Haminer) filter(halog *Halog) bool {
if halog == nil {
return false
}
+ if halog.BackendName == `-` {
+ return false
+ }
if len(h.cfg.AcceptBackend) == 0 {
return true
}
@@ -133,11 +136,6 @@ func (h *Haminer) consume() {
}
func (h *Haminer) forwards(halogs []*Halog) {
- // Send heartbeat indicator, if logs is empty.
- if len(halogs) == 0 {
- heartbeat.Timestamp = time.Now()
- halogs = append(halogs, heartbeat)
- }
for _, fwder := range h.ff {
fwder.Forwards(halogs)
}
@@ -158,11 +156,15 @@ func (h *Haminer) produce() {
select {
case halog := <-h.chHalog:
h.preprocess(halog)
-
halogs = append(halogs, halog)
+
case <-ticker.C:
+ if len(halogs) == 0 {
+ continue
+ }
+
h.forwards(halogs)
- halogs = nil
+ halogs = halogs[:0]
}
}
}