From ba81f584c5f732dbbac9273c56bad71a5c8f00aa Mon Sep 17 00:00:00 2001 From: Aleksandr Maus Date: Tue, 1 Oct 2024 09:11:08 -0400 Subject: [PATCH] [filebeat]: improve debug logging in udp/tcp inputs (#41059) --- filebeat/input/tcp/input.go | 1 + filebeat/input/udp/input.go | 1 + filebeat/input/unix/input.go | 1 + filebeat/inputsource/common/streaming/listener.go | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/filebeat/input/tcp/input.go b/filebeat/input/tcp/input.go index 2502594b1aa2..3e65c90d7a07 100644 --- a/filebeat/input/tcp/input.go +++ b/filebeat/input/tcp/input.go @@ -109,6 +109,7 @@ func (s *server) Run(ctx input.Context, publisher stateless.Publisher) error { server, err := tcp.New(&s.config.Config, streaming.SplitHandlerFactory( inputsource.FamilyTCP, log, tcp.MetadataCallback, func(data []byte, metadata inputsource.NetworkMetadata) { + log.Debugw("Data received", "bytes", len(data), "remote_address", metadata.RemoteAddr.String(), "truncated", metadata.Truncated) evt := beat.Event{ Timestamp: time.Now(), Fields: mapstr.M{ diff --git a/filebeat/input/udp/input.go b/filebeat/input/udp/input.go index 190b77663ac4..b6f4483c6fb5 100644 --- a/filebeat/input/udp/input.go +++ b/filebeat/input/udp/input.go @@ -99,6 +99,7 @@ func (s *server) Run(ctx input.Context, publisher stateless.Publisher) error { defer metrics.Close() server := udp.New(&s.config.Config, func(data []byte, metadata inputsource.NetworkMetadata) { + log.Debugw("Data received", "bytes", len(data), "remote_address", metadata.RemoteAddr.String(), "truncated", metadata.Truncated) evt := beat.Event{ Timestamp: time.Now(), Meta: mapstr.M{ diff --git a/filebeat/input/unix/input.go b/filebeat/input/unix/input.go index cb7f05e356e8..6812fa613535 100644 --- a/filebeat/input/unix/input.go +++ b/filebeat/input/unix/input.go @@ -102,6 +102,7 @@ func (s *server) Run(ctx input.Context, publisher stateless.Publisher) error { defer metrics.close() server, err := unix.New(log, &s.config.Config, func(data []byte, _ inputsource.NetworkMetadata) { + log.Debugw("Data received", "bytes", len(data)) evt := beat.Event{ Timestamp: time.Now(), Fields: mapstr.M{ diff --git a/filebeat/inputsource/common/streaming/listener.go b/filebeat/inputsource/common/streaming/listener.go index 69fb077144c4..ce0f69d030e6 100644 --- a/filebeat/inputsource/common/streaming/listener.go +++ b/filebeat/inputsource/common/streaming/listener.go @@ -191,10 +191,10 @@ func (l *Listener) handleConnection(conn net.Conn) { // Track number of clients. l.clientsCount.Inc() - log.Debugw("New client connection.", "active_clients", l.clientsCount.Load()) + log.Debugw("New client connection", "active_clients", l.clientsCount.Load()) defer func() { l.clientsCount.Dec() - log.Debugw("Client disconnected.", "active_clients", l.clientsCount.Load()) + log.Debugw("Client disconnected", "active_clients", l.clientsCount.Load()) }() handler := l.handlerFactory(*l.config)