aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--halog.go10
-rw-r--r--haminer.go16
2 files changed, 9 insertions, 17 deletions
diff --git a/halog.go b/halog.go
index fd3f432..b7ac16d 100644
--- a/halog.go
+++ b/halog.go
@@ -11,16 +11,6 @@ import (
"time"
)
-// heartbeat of haminer, in case we want to monitor deadman from haminer.
-var heartbeat = &Halog{ // nolint: gochecknoglobals
- Timestamp: time.Now(),
- FrontendName: "-",
- BackendName: "-",
- ServerName: "-",
- tagHTTPURL: "-",
- HTTPMethod: "-",
-}
-
// Halog contains the mapping of haproxy HTTP log format to Go struct.
//
// Reference: https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8.2.3
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]
}
}
}