Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(promtail): Fix UDP receiver on syslog transport #10708

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Starting with the 3.0 release we began using [conventional commits](https://www.

##### Fixes

* [10708](https://github.com/grafana/loki/pull/10708) **joshuapare**: Fix UDP receiver on syslog transport
* [10631](https://github.com/grafana/loki/pull/10631) **thampiotr**: Fix race condition in cleaning up metrics when stopping to tail files.
* [10798](https://github.com/grafana/loki/pull/10798) **hainenber**: Fix agent panicking after reloaded due to duplicate metric collector registration.
* [10848](https://github.com/grafana/loki/pull/10848) **rgroothuijsen**: Correctly parse list of drop stage sources from YAML.
Expand Down
33 changes: 25 additions & 8 deletions clients/pkg/promtail/targets/syslog/transport.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package syslog

import (
"bytes"
"context"
"crypto/tls"
"crypto/x509"
Expand Down Expand Up @@ -380,16 +381,32 @@ func (t *UDPTransport) handleRcv(c *ConnPipe) {
defer t.openConnections.Done()

lbs := t.connectionLabels(c.addr.String())
err := syslogparser.ParseStream(c, func(result *syslog.Result) {
if err := result.Error; err != nil {
t.handleMessageError(err)
} else {
t.handleMessage(lbs.Copy(), result.Message)

for {
datagram := make([]byte, t.maxMessageLength())
n, err := c.Read(datagram)
if err != nil {
if err == io.EOF {
break
}

level.Warn(t.logger).Log("msg", "error reading from pipe", "err", err)
continue
}
}, t.maxMessageLength())

if err != nil {
level.Warn(t.logger).Log("msg", "error parsing syslog stream", "err", err)
r := bytes.NewReader(datagram[:n])

err = syslogparser.ParseStream(r, func(result *syslog.Result) {
if err := result.Error; err != nil {
t.handleMessageError(err)
} else {
t.handleMessage(lbs.Copy(), result.Message)
}
}, t.maxMessageLength())

if err != nil {
level.Warn(t.logger).Log("msg", "error parsing syslog stream", "err", err)
}
}
}

Expand Down
Loading