Skip to content

Commit

Permalink
[filebeat]: improve debug logging in udp/tcp inputs (#41059)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksmaus authored Oct 1, 2024
1 parent c5d376c commit ba81f58
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions filebeat/input/tcp/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions filebeat/input/udp/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions filebeat/input/unix/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions filebeat/inputsource/common/streaming/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba81f58

Please sign in to comment.