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

Non-transparent transport of syslog messages #5148

Merged
merged 11 commits into from
Dec 18, 2018
25 changes: 20 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

[[constraint]]
name = "github.com/influxdata/go-syslog"
version = "1.0.1"
branch = "feature/rfc6587"
leodido marked this conversation as resolved.
Show resolved Hide resolved

[[constraint]]
name = "github.com/influxdata/tail"
Expand Down
23 changes: 20 additions & 3 deletions plugins/inputs/syslog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

The syslog plugin listens for syslog messages transmitted over
[UDP](https://tools.ietf.org/html/rfc5426) or
[TCP](https://tools.ietf.org/html/rfc5425).
[TCP](https://tools.ietf.org/html/rfc6587) or
[TLS](https://tools.ietf.org/html/rfc5425), with or without the octet counting framing.

Syslog messages should be formatted according to
[RFC 5424](https://tools.ietf.org/html/rfc5424).
Expand Down Expand Up @@ -37,6 +38,15 @@ Syslog messages should be formatted according to
## 0 means unlimited.
# read_timeout = "5s"

## Whether the messages come using the transparent framing or not (default = false).
## When false messages come using non-transparent framing technique (RFC6587#section-3.4.2).
## True means messages come using octect-counting framing technique (RFC5425#section-4.3.1 and RFC6587#section-3.4.1).
# transparent_framing = false
leodido marked this conversation as resolved.
Show resolved Hide resolved

## The trailer to be expected in case of non-trasparent framing (default = "LF").
## Must be one of "LF", or "NUL".
# trailer = "LF"

## Whether to parse in best effort mode or not (default = false).
## By default best effort parsing is off.
# best_effort = false
Expand All @@ -49,11 +59,18 @@ Syslog messages should be formatted according to
# sdparam_separator = "_"
```

#### Best Effort
#### Message transport

The `transparent_framing` option only applies to streams. It governs the way we expect to receive messages within the stream.
With the [octet counting](https://tools.ietf.org/html/rfc5425#section-4.3) technique or with the [non-transparent](https://tools.ietf.org/html/rfc6587#section-3.4.2) framing.

The `trailer` option only applies when `transparent_framing` is `false` - ie., non-transparent transport.

#### Best effort

The [`best_effort`](https://github.com/influxdata/go-syslog#best-effort-mode)
option instructs the parser to extract partial but valid info from syslog
messages. If unset only full messages will be collected.
messages. If unset only full messages will be collected.

#### Rsyslog Integration

Expand Down
62 changes: 62 additions & 0 deletions plugins/inputs/syslog/commons_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package syslog

import (
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/testutil"
"time"
)

var (
pki = testutil.NewPKI("../../../testutil/pki")
)

type testCasePacket struct {
name string
data []byte
wantBestEffort *testutil.Metric
wantStrict *testutil.Metric
werr bool
}

type testCaseStream struct {
name string
data []byte
wantBestEffort []testutil.Metric
wantStrict []testutil.Metric
werr int // how many errors we expect in the strict mode?
}

func newUDPSyslogReceiver(address string, bestEffort bool) *Syslog {
return &Syslog{
Address: address,
now: func() time.Time {
return defaultTime
},
BestEffort: bestEffort,
Separator: "_",
}
}

func newTCPSyslogReceiver(address string, keepAlive *internal.Duration, maxConn int, bestEffort bool, transparent bool) *Syslog {
d := &internal.Duration{
Duration: defaultReadTimeout,
}
s := &Syslog{
Address: address,
now: func() time.Time {
return defaultTime
},
TransparentFraming: transparent,
ReadTimeout: d,
BestEffort: bestEffort,
Separator: "_",
}
if keepAlive != nil {
s.KeepAlivePeriod = keepAlive
}
if maxConn > 0 {
s.MaxConnections = maxConn
}

return s
}
Loading