test(inputs.syslog): Migrate unit-tests to test-cases (#14784)

This commit is contained in:
Sven Rebhan 2024-02-13 15:16:21 +01:00 committed by GitHub
parent bb62677b2d
commit 2874ad13aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
161 changed files with 534 additions and 1496 deletions

View File

@ -1,65 +0,0 @@
package syslog
import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
framing "github.com/influxdata/telegraf/internal/syslog"
"github.com/influxdata/telegraf/testutil"
)
var (
pki = testutil.NewPKI("../../../testutil/pki")
)
type testCasePacket struct {
name string
data []byte
wantBestEffort telegraf.Metric
wantStrict telegraf.Metric
werr bool
}
type testCaseStream struct {
name string
data []byte
wantBestEffort []telegraf.Metric
wantStrict []telegraf.Metric
werr int // how many errors we expect in the strict mode?
}
func newUDPSyslogReceiver(address string, bestEffort bool, rfc syslogRFC) *Syslog {
return &Syslog{
Address: address,
now: func() time.Time {
return defaultTime
},
BestEffort: bestEffort,
SyslogStandard: rfc,
Separator: "_",
}
}
func newTCPSyslogReceiver(address string, keepAlive *config.Duration, maxConn int, bestEffort bool, f framing.Framing) *Syslog {
d := config.Duration(defaultReadTimeout)
s := &Syslog{
Address: address,
now: func() time.Time {
return defaultTime
},
Framing: f,
ReadTimeout: &d,
BestEffort: bestEffort,
SyslogStandard: syslogRFC5424,
Separator: "_",
}
if keepAlive != nil {
s.KeepAlivePeriod = keepAlive
}
if maxConn > 0 {
s.MaxConnections = maxConn
}
return s
}

View File

@ -1,302 +0,0 @@
package syslog
import (
"crypto/tls"
"net"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
framing "github.com/influxdata/telegraf/internal/syslog"
"github.com/influxdata/telegraf/testutil"
)
func getTestCasesForNonTransparent(hasRemoteAddr bool) []testCaseStream {
testCases := []testCaseStream{
{
name: "1st/avg/ok",
data: []byte(
`<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] ` +
`"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
},
werr: 1,
},
{
name: "1st/min/ok//2nd/min/ok",
data: []byte("<1>2 - - - - - -\n<4>11 - - - - - -\n"),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "warning",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(11),
"severity_code": 4,
"facility_code": 0,
},
defaultTime.Add(time.Nanosecond),
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "warning",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(11),
"severity_code": 4,
"facility_code": 0,
},
defaultTime.Add(time.Nanosecond),
),
},
},
}
if hasRemoteAddr {
for _, tc := range testCases {
for _, m := range tc.wantStrict {
m.AddTag("source", "127.0.0.1")
}
for _, m := range tc.wantBestEffort {
m.AddTag("source", "127.0.0.1")
}
}
}
return testCases
}
func testStrictNonTransparent(t *testing.T, protocol string, address string, wantTLS bool, keepAlive *config.Duration) {
for _, tc := range getTestCasesForNonTransparent(protocol != "unix") {
t.Run(tc.name, func(t *testing.T) {
// Creation of a strict mode receiver
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 10, false, framing.NonTransparent)
require.NotNil(t, receiver)
if wantTLS {
receiver.ServerConfig = *pki.TLSServerConfig()
}
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
var conn net.Conn
var err error
if wantTLS {
config, e := pki.TLSClientConfig().TLSConfig()
require.NoError(t, e)
config.ServerName = "localhost"
conn, err = tls.Dial(protocol, address, config)
require.NotNil(t, conn)
require.NoError(t, err)
} else {
conn, err = net.Dial(protocol, address)
require.NotNil(t, conn)
require.NoError(t, err)
defer conn.Close()
}
// Clear
acc.ClearMetrics()
acc.Errors = make([]error, 0)
// Write
_, err = conn.Write(tc.data)
conn.Close()
require.NoError(t, err)
// Wait that the number of data points is accumulated
// Since the receiver is running concurrently
if tc.wantStrict != nil {
acc.Wait(len(tc.wantStrict))
}
// Wait the parsing error
acc.WaitError(tc.werr)
// Verify
if len(acc.Errors) != tc.werr {
t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tc.werr, acc.Errors)
}
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
})
}
}
func testBestEffortNonTransparent(t *testing.T, protocol string, address string, wantTLS bool) {
keepAlive := (*config.Duration)(nil)
for _, tc := range getTestCasesForNonTransparent(protocol != "unix") {
t.Run(tc.name, func(t *testing.T) {
// Creation of a best effort mode receiver
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 10, true, framing.NonTransparent)
require.NotNil(t, receiver)
if wantTLS {
receiver.ServerConfig = *pki.TLSServerConfig()
}
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
var conn net.Conn
var err error
if wantTLS {
config, e := pki.TLSClientConfig().TLSConfig()
require.NoError(t, e)
config.ServerName = "localhost"
conn, err = tls.Dial(protocol, address, config)
} else {
conn, err = net.Dial(protocol, address)
}
require.NotNil(t, conn)
require.NoError(t, err)
// Clear
acc.ClearMetrics()
acc.Errors = make([]error, 0)
// Write
_, err = conn.Write(tc.data)
require.NoError(t, err)
conn.Close()
// Wait that the number of data points is accumulated
// Since the receiver is running concurrently
if tc.wantBestEffort != nil {
acc.Wait(len(tc.wantBestEffort))
}
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
})
}
}
func TestNonTransparentStrict_tcp(t *testing.T) {
testStrictNonTransparent(t, "tcp", address, false, nil)
}
func TestNonTransparentBestEffort_tcp(t *testing.T) {
testBestEffortNonTransparent(t, "tcp", address, false)
}
func TestNonTransparentStrict_tcp_tls(t *testing.T) {
testStrictNonTransparent(t, "tcp", address, true, nil)
}
func TestNonTransparentBestEffort_tcp_tls(t *testing.T) {
testBestEffortNonTransparent(t, "tcp", address, true)
}
func TestNonTransparentStrictWithKeepAlive_tcp_tls(t *testing.T) {
d := config.Duration(time.Minute)
testStrictNonTransparent(t, "tcp", address, true, &d)
}
func TestNonTransparentStrictWithZeroKeepAlive_tcp_tls(t *testing.T) {
d := config.Duration(0)
testStrictNonTransparent(t, "tcp", address, true, &d)
}
func TestNonTransparentStrict_unix(t *testing.T) {
sock := testutil.TempSocket(t)
testStrictNonTransparent(t, "unix", sock, false, nil)
}
func TestNonTransparentBestEffort_unix(t *testing.T) {
sock := testutil.TempSocket(t)
testBestEffortNonTransparent(t, "unix", sock, false)
}
func TestNonTransparentStrict_unix_tls(t *testing.T) {
sock := testutil.TempSocket(t)
testStrictNonTransparent(t, "unix", sock, true, nil)
}
func TestNonTransparentBestEffort_unix_tls(t *testing.T) {
sock := testutil.TempSocket(t)
testBestEffortNonTransparent(t, "unix", sock, true)
}

View File

@ -1,501 +0,0 @@
package syslog
import (
"crypto/tls"
"fmt"
"net"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
framing "github.com/influxdata/telegraf/internal/syslog"
"github.com/influxdata/telegraf/testutil"
)
func getTestCasesForOctetCounting(hasRemoteAddr bool) []testCaseStream {
testCases := []testCaseStream{
{
name: "1st/avg/ok",
data: []byte(
`188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] ` +
`"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
},
},
{
name: "1st/min/ok//2nd/min/ok",
data: []byte("16 <1>2 - - - - - -17 <4>11 - - - - - -"),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "warning",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(11),
"severity_code": 4,
"facility_code": 0,
},
defaultTime.Add(time.Nanosecond),
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "warning",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(11),
"severity_code": 4,
"facility_code": 0,
},
defaultTime.Add(time.Nanosecond),
),
},
},
{
name: "1st/utf8/ok",
data: []byte("23 <1>1 - - - - - - hellø"),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "hellø",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "hellø",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
},
{
name: "1st/nl/ok", // newline
data: []byte("28 <1>3 - - - - - - hello\nworld"),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(3),
"message": "hello\nworld",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(3),
"message": "hello\nworld",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
},
{
name: "1st/uf/ko", // underflow (msglen less than provided octets)
data: []byte("16 <1>2"),
wantStrict: nil,
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
werr: 1,
},
{
name: "1st/min/ok",
data: []byte("16 <1>1 - - - - - -"),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
},
{
name: "1st/uf/mf", // The first "underflow" message breaks also the second one
data: []byte("16 <1>217 <11>1 - - - - - -"),
wantStrict: nil,
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(217),
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
werr: 1,
},
// {
// name: "1st/of/ko", // overflow (msglen greater than max allowed octets)
// data: []byte(fmt.Sprintf("8193 <%d>%d %s %s %s %s %s 12 %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
// want: []testutil.Metric{},
// },
{
name: "1st/max/ok",
data: []byte(fmt.Sprintf("8192 <%d>%d %s %s %s %s %s - %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
wantStrict: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "debug",
"facility": "local7",
"hostname": maxH,
"appname": maxA,
},
map[string]interface{}{
"version": maxV,
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
"message": message7681,
"procid": maxPID,
"msgid": maxMID,
"facility_code": 23,
"severity_code": 7,
},
defaultTime,
),
},
wantBestEffort: []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "debug",
"facility": "local7",
"hostname": maxH,
"appname": maxA,
},
map[string]interface{}{
"version": maxV,
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
"message": message7681,
"procid": maxPID,
"msgid": maxMID,
"facility_code": 23,
"severity_code": 7,
},
defaultTime,
),
},
},
}
if hasRemoteAddr {
for _, tc := range testCases {
for _, m := range tc.wantStrict {
m.AddTag("source", "127.0.0.1")
}
for _, m := range tc.wantBestEffort {
m.AddTag("source", "127.0.0.1")
}
}
}
return testCases
}
func testStrictOctetCounting(t *testing.T, protocol string, address string, wantTLS bool, keepAlive *config.Duration) {
for _, tc := range getTestCasesForOctetCounting(protocol != "unix") {
t.Run(tc.name, func(t *testing.T) {
// Creation of a strict mode receiver
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 0, false, framing.OctetCounting)
require.NotNil(t, receiver)
if wantTLS {
receiver.ServerConfig = *pki.TLSServerConfig()
}
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
var conn net.Conn
var err error
if wantTLS {
config, e := pki.TLSClientConfig().TLSConfig()
require.NoError(t, e)
config.ServerName = "localhost"
conn, err = tls.Dial(protocol, address, config)
require.NotNil(t, conn)
require.NoError(t, err)
} else {
conn, err = net.Dial(protocol, address)
require.NotNil(t, conn)
require.NoError(t, err)
defer conn.Close()
}
// Clear
acc.ClearMetrics()
acc.Errors = make([]error, 0)
// Write
_, err = conn.Write(tc.data)
conn.Close()
require.NoError(t, err)
// Wait that the number of data points is accumulated
// Since the receiver is running concurrently
if tc.wantStrict != nil {
acc.Wait(len(tc.wantStrict))
}
// Wait the parsing error
acc.WaitError(tc.werr)
// Verify
if len(acc.Errors) != tc.werr {
t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tc.werr, acc.Errors)
}
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
})
}
}
func testBestEffortOctetCounting(t *testing.T, protocol string, address string, wantTLS bool) {
keepAlive := (*config.Duration)(nil)
for _, tc := range getTestCasesForOctetCounting(protocol != "unix") {
t.Run(tc.name, func(t *testing.T) {
// Creation of a best effort mode receiver
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 0, true, framing.OctetCounting)
require.NotNil(t, receiver)
if wantTLS {
receiver.ServerConfig = *pki.TLSServerConfig()
}
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
var conn net.Conn
var err error
if wantTLS {
config, e := pki.TLSClientConfig().TLSConfig()
require.NoError(t, e)
config.ServerName = "localhost"
conn, err = tls.Dial(protocol, address, config)
} else {
conn, err = net.Dial(protocol, address)
}
require.NotNil(t, conn)
require.NoError(t, err)
// Clear
acc.ClearMetrics()
acc.Errors = make([]error, 0)
// Write
_, err = conn.Write(tc.data)
require.NoError(t, err)
conn.Close()
// Wait that the number of data points is accumulated
// Since the receiver is running concurrently
if tc.wantBestEffort != nil {
acc.Wait(len(tc.wantBestEffort))
}
testutil.RequireMetricsEqual(t, tc.wantBestEffort, acc.GetTelegrafMetrics())
})
}
}
func TestOctetCountingStrict_tcp(t *testing.T) {
testStrictOctetCounting(t, "tcp", address, false, nil)
}
func TestOctetCountingBestEffort_tcp(t *testing.T) {
testBestEffortOctetCounting(t, "tcp", address, false)
}
func TestOctetCountingStrict_tcp_tls(t *testing.T) {
testStrictOctetCounting(t, "tcp", address, true, nil)
}
func TestOctetCountingBestEffort_tcp_tls(t *testing.T) {
testBestEffortOctetCounting(t, "tcp", address, true)
}
func TestOctetCountingStrictWithKeepAlive_tcp_tls(t *testing.T) {
d := config.Duration(time.Minute)
testStrictOctetCounting(t, "tcp", address, true, &d)
}
func TestOctetCountingStrictWithZeroKeepAlive_tcp_tls(t *testing.T) {
d := config.Duration(0)
testStrictOctetCounting(t, "tcp", address, true, &d)
}
func TestOctetCountingStrict_unix(t *testing.T) {
sock := testutil.TempSocket(t)
testStrictOctetCounting(t, "unix", sock, false, nil)
}
func TestOctetCountingBestEffort_unix(t *testing.T) {
sock := testutil.TempSocket(t)
testBestEffortOctetCounting(t, "unix", sock, false)
}
func TestOctetCountingStrict_unix_tls(t *testing.T) {
sock := testutil.TempSocket(t)
testStrictOctetCounting(t, "unix", sock, true, nil)
}
func TestOctetCountingBestEffort_unix_tls(t *testing.T) {
sock := testutil.TempSocket(t)
testBestEffortOctetCounting(t, "unix", sock, true)
}

View File

@ -1,137 +0,0 @@
package syslog
import (
"errors"
"fmt"
"net"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/testutil"
)
func timeMustParse(value string) time.Time {
format := "Jan 2 15:04:05 2006"
t, err := time.Parse(format, value)
if err != nil {
panic(fmt.Sprintf("couldn't parse time: %v", value))
}
return t
}
func getTestCasesForRFC3164(hasRemoteAddr bool) []testCasePacket {
currentYear := time.Now().Year()
ts := timeMustParse(fmt.Sprintf("Dec 2 16:31:03 %d", currentYear)).UnixNano()
testCases := []testCasePacket{
{
name: "complete",
data: []byte("<13>Dec 2 16:31:03 host app: Test"),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"appname": "app",
"severity": "notice",
"hostname": "host",
"facility": "user",
},
map[string]interface{}{
"timestamp": ts,
"message": "Test",
"facility_code": 1,
"severity_code": 5,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"appname": "app",
"severity": "notice",
"hostname": "host",
"facility": "user",
},
map[string]interface{}{
"timestamp": ts,
"message": "Test",
"facility_code": 1,
"severity_code": 5,
},
defaultTime,
),
},
}
if hasRemoteAddr {
for _, tc := range testCases {
if tc.wantStrict != nil {
tc.wantStrict.AddTag("source", "127.0.0.1")
}
if tc.wantBestEffort != nil {
tc.wantBestEffort.AddTag("source", "127.0.0.1")
}
}
}
return testCases
}
func testRFC3164(t *testing.T, protocol string, address string, bestEffort bool) {
for _, tc := range getTestCasesForRFC3164(protocol != "unix") {
t.Run(tc.name, func(t *testing.T) {
// Create receiver
receiver := newUDPSyslogReceiver(protocol+"://"+address, bestEffort, syslogRFC3164)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
conn, err := net.Dial(protocol, address)
require.NotNil(t, conn)
require.NoError(t, err)
// Write
_, err = conn.Write(tc.data)
conn.Close()
if err != nil {
var opErr *net.OpError
if errors.As(err, &opErr) {
if opErr.Err.Error() == "write: message too long" {
return
}
}
}
// Waiting ...
if tc.wantStrict == nil && tc.werr || bestEffort && tc.werr {
acc.WaitError(1)
}
if tc.wantBestEffort != nil && bestEffort || tc.wantStrict != nil && !bestEffort {
acc.Wait(1) // RFC3164 mandates a syslog message per UDP packet
}
// Compare
var got telegraf.Metric
var want telegraf.Metric
if len(acc.Metrics) > 0 {
got = acc.GetTelegrafMetrics()[0]
}
if bestEffort {
want = tc.wantBestEffort
} else {
want = tc.wantStrict
}
testutil.RequireMetricEqual(t, want, got)
})
}
}
func TestRFC3164BestEffort_udp(t *testing.T) {
testRFC3164(t, "udp", address, true)
}
func TestRFC3164Strict_udp(t *testing.T) {
testRFC3164(t, "udp", address, false)
}

View File

@ -1,441 +0,0 @@
package syslog
import (
"errors"
"fmt"
"net"
"os"
"runtime"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/testutil"
)
func getTestCasesForRFC5426(hasRemoteAddr bool) []testCasePacket {
testCases := []testCasePacket{
{
name: "complete",
data: []byte("<1>1 - - - - - - A"),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "A",
"facility_code": 0,
"severity_code": 1,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "A",
"facility_code": 0,
"severity_code": 1,
},
defaultTime,
),
},
{
name: "one/per/packet",
data: []byte("<1>3 - - - - - - A<1>4 - - - - - - B"),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(3),
"message": "A<1>4 - - - - - - B",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(3),
"message": "A<1>4 - - - - - - B",
"severity_code": 1,
"facility_code": 0,
},
defaultTime,
),
},
{
name: "average",
data: []byte(
`<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] ` +
`"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
defaultTime,
),
},
{
name: "max",
data: []byte(fmt.Sprintf("<%d>%d %s %s %s %s %s - %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "debug",
"facility": "local7",
"hostname": maxH,
"appname": maxA,
},
map[string]interface{}{
"version": maxV,
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
"message": message7681,
"procid": maxPID,
"msgid": maxMID,
"severity_code": 7,
"facility_code": 23,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "debug",
"facility": "local7",
"hostname": maxH,
"appname": maxA,
},
map[string]interface{}{
"version": maxV,
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
"message": message7681,
"procid": maxPID,
"msgid": maxMID,
"severity_code": 7,
"facility_code": 23,
},
defaultTime,
),
},
{
name: "minimal/incomplete",
data: []byte("<1>2"),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(2),
"facility_code": 0,
"severity_code": 1,
},
defaultTime,
),
werr: true,
},
{
name: "trim message",
data: []byte("<1>1 - - - - - - \tA\n"),
wantBestEffort: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "\tA",
"facility_code": 0,
"severity_code": 1,
},
defaultTime,
),
wantStrict: testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
},
map[string]interface{}{
"version": uint16(1),
"message": "\tA",
"facility_code": 0,
"severity_code": 1,
},
defaultTime,
),
},
}
if hasRemoteAddr {
for _, tc := range testCases {
if tc.wantStrict != nil {
tc.wantStrict.AddTag("source", "127.0.0.1")
}
if tc.wantBestEffort != nil {
tc.wantBestEffort.AddTag("source", "127.0.0.1")
}
}
}
return testCases
}
func testRFC5426(t *testing.T, protocol string, address string, bestEffort bool) {
for _, tc := range getTestCasesForRFC5426(protocol != "unixgram") {
t.Run(tc.name, func(t *testing.T) {
// Create receiver
receiver := newUDPSyslogReceiver(protocol+"://"+address, bestEffort, syslogRFC5424)
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
conn, err := net.Dial(protocol, address)
require.NotNil(t, conn)
require.NoError(t, err)
// Write
_, err = conn.Write(tc.data)
conn.Close()
if err != nil {
var opErr *net.OpError
if errors.As(err, &opErr) {
if opErr.Err.Error() == "write: message too long" {
return
}
}
}
// Waiting ...
if tc.wantStrict == nil && tc.werr || bestEffort && tc.werr {
acc.WaitError(1)
}
if tc.wantBestEffort != nil && bestEffort || tc.wantStrict != nil && !bestEffort {
acc.Wait(1) // RFC5426 mandates a syslog message per UDP packet
}
// Compare
var got telegraf.Metric
var want telegraf.Metric
if len(acc.Metrics) > 0 {
got = acc.GetTelegrafMetrics()[0]
}
if bestEffort {
want = tc.wantBestEffort
} else {
want = tc.wantStrict
}
testutil.RequireMetricEqual(t, want, got)
})
}
}
func TestBestEffort_udp(t *testing.T) {
testRFC5426(t, "udp", address, true)
}
func TestStrict_udp(t *testing.T) {
testRFC5426(t, "udp", address, false)
}
func TestBestEffort_unixgram(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows, as unixgram sockets are not supported")
}
sock := testutil.TempSocket(t)
f, err := os.Create(sock)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, f.Close()) })
testRFC5426(t, "unixgram", sock, true)
}
func TestStrict_unixgram(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows, as unixgram sockets are not supported")
}
sock := testutil.TempSocket(t)
f, err := os.Create(sock)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, f.Close()) })
testRFC5426(t, "unixgram", sock, false)
}
func TestTimeIncrement_udp(t *testing.T) {
var i int64
atomic.StoreInt64(&i, 0)
getNow := func() time.Time {
if atomic.LoadInt64(&i)%2 == 0 {
return time.Unix(1, 0)
}
return time.Unix(1, 1)
}
// Create receiver
receiver := &Syslog{
Address: "udp://" + address,
now: getNow,
BestEffort: false,
SyslogStandard: syslogRFC5424,
Separator: "_",
}
acc := &testutil.Accumulator{}
require.NoError(t, receiver.Start(acc))
defer receiver.Stop()
// Connect
conn, err := net.Dial("udp", address)
require.NotNil(t, conn)
defer conn.Close()
require.NoError(t, err)
// Write
_, e := conn.Write([]byte("<1>1 - - - - - -"))
require.NoError(t, e)
// Wait
acc.Wait(1)
want := []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
"source": "127.0.0.1",
},
map[string]interface{}{
"version": uint16(1),
"facility_code": 0,
"severity_code": 1,
},
getNow(),
),
}
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
// New one with different time
atomic.StoreInt64(&i, atomic.LoadInt64(&i)+1)
// Clear
acc.ClearMetrics()
// Write
_, e = conn.Write([]byte("<1>1 - - - - - -"))
require.NoError(t, e)
// Wait
acc.Wait(1)
want = []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
"source": "127.0.0.1",
},
map[string]interface{}{
"version": uint16(1),
"facility_code": 0,
"severity_code": 1,
},
getNow(),
),
}
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
// New one with same time as previous one
// Clear
acc.ClearMetrics()
// Write
_, e = conn.Write([]byte("<1>1 - - - - - -"))
require.NoError(t, e)
// Wait
acc.Wait(1)
want = []telegraf.Metric{
testutil.MustMetric(
"syslog",
map[string]string{
"severity": "alert",
"facility": "kern",
"source": "127.0.0.1",
},
map[string]interface{}{
"version": uint16(1),
"facility_code": 0,
"severity_code": 1,
},
getNow().Add(time.Nanosecond),
),
}
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
}

View File

@ -1,6 +1,10 @@
package syslog
import (
"crypto/tls"
"net"
"net/url"
"os"
"path/filepath"
"runtime"
"strings"
@ -9,62 +13,267 @@ import (
"github.com/stretchr/testify/require"
"github.com/influxdata/go-syslog/v3/nontransparent"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
framing "github.com/influxdata/telegraf/internal/syslog"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/inputs"
influx "github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
"github.com/influxdata/telegraf/testutil"
)
const (
address = ":6514"
)
var pki = testutil.NewPKI("../../../testutil/pki")
var defaultTime = time.Unix(0, 0)
var maxP = uint8(191)
var maxV = uint16(999)
var maxTS = "2017-12-31T23:59:59.999999+00:00"
var maxH = "abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqr" +
"stuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabc"
var maxA = "abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdef"
var maxPID = "abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzab"
var maxMID = "abcdefghilmnopqrstuvzabcdefghilm"
var message7681 = strings.Repeat("l", 7681)
func TestAddress(t *testing.T) {
var err error
var rec *Syslog
rec = &Syslog{
Address: "localhost:6514",
}
err = rec.Start(&testutil.Accumulator{})
require.EqualError(t, err, `missing protocol within address "localhost:6514"`)
require.Error(t, err)
rec = &Syslog{
Address: "unsupported://example.com:6514",
}
err = rec.Start(&testutil.Accumulator{})
require.EqualError(t, err, `unknown protocol "unsupported" in "example.com:6514"`)
require.Error(t, err)
tmpdir := t.TempDir()
sock := filepath.Join(tmpdir, "syslog.TestAddress.sock")
if runtime.GOOS != "windows" {
// Skipping on Windows, as unixgram sockets are not supported
rec = &Syslog{
Address: "unixgram://" + sock,
}
err = rec.Start(&testutil.Accumulator{})
require.NoError(t, err)
require.Equal(t, sock, rec.Address)
rec.Stop()
func TestInitFail(t *testing.T) {
tests := []struct {
name string
address string
expected string
}{
{
name: "no address",
expected: "missing protocol within address",
},
{
name: "missing protocol",
address: "localhost:6514",
expected: "missing protocol within address",
},
{
name: "unknown protocol",
address: "unsupported://example.com:6514",
expected: "unknown protocol",
},
}
// Default port is 6514
rec = &Syslog{
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
plugin := &Syslog{
Address: tt.address,
}
var acc testutil.Accumulator
require.ErrorContains(t, plugin.Start(&acc), tt.expected)
})
}
}
func TestAddressDefaultPort(t *testing.T) {
plugin := &Syslog{
Address: "tcp://localhost",
}
err = rec.Start(&testutil.Accumulator{})
require.NoError(t, err)
require.Equal(t, "localhost:6514", rec.Address)
rec.Stop()
var acc testutil.Accumulator
require.NoError(t, plugin.Start(&acc))
defer plugin.Stop()
// Default port is 6514
require.Equal(t, "localhost:6514", plugin.Address)
}
func TestUnixgram(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping test as unixgram is not supported on Windows")
}
// Create the socket
sock := testutil.TempSocket(t)
f, err := os.Create(sock)
require.NoError(t, err)
defer f.Close()
// Setup plugin and start it
timeout := config.Duration(defaultReadTimeout)
plugin := &Syslog{
Address: "unixgram://" + sock,
Framing: framing.OctetCounting,
ReadTimeout: &timeout,
Separator: "_",
SyslogStandard: "RFC5424",
Trailer: nontransparent.LF,
now: getNanoNow,
}
var acc testutil.Accumulator
require.NoError(t, plugin.Start(&acc))
defer plugin.Stop()
// Send the message
//nolint:lll // conditionally long lines allowed
msg := `<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`
client, err := net.Dial("unixgram", sock)
require.NoError(t, err)
defer client.Close()
_, err = client.Write([]byte(msg))
require.NoError(t, err)
// Do the comparison
expected := []telegraf.Metric{
metric.New(
"syslog",
map[string]string{
"severity": "notice",
"facility": "daemon",
"hostname": "web1",
"appname": "someservice",
},
map[string]interface{}{
"version": uint16(1),
"timestamp": time.Unix(1456029177, 0).UnixNano(),
"procid": "2341",
"msgid": "2",
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
"origin": true,
"meta_sequence": "14125553",
"meta_service": "someservice",
"severity_code": 5,
"facility_code": 3,
},
time.Unix(0, 0),
),
}
client.Close()
// Check the metric nevertheless as we might get some metrics despite errors.
require.Eventually(t, func() bool {
return int(acc.NMetrics()) >= len(expected)
}, 3*time.Second, 100*time.Millisecond)
plugin.Stop()
actual := acc.GetTelegrafMetrics()
testutil.RequireMetricsEqual(t, expected, actual, testutil.IgnoreTime())
}
func TestCases(t *testing.T) {
// Get all directories in testdata
folders, err := os.ReadDir("testcases")
require.NoError(t, err)
// Register the plugin
inputs.Add("syslog", func() telegraf.Input {
defaultTimeout := config.Duration(defaultReadTimeout)
return &Syslog{
Address: ":6514",
now: getNanoNow,
ReadTimeout: &defaultTimeout,
Framing: framing.OctetCounting,
SyslogStandard: syslogRFC5424,
Trailer: nontransparent.LF,
Separator: "_",
}
})
for _, f := range folders {
// Only handle folders
if !f.IsDir() {
continue
}
t.Run(f.Name(), func(t *testing.T) {
testcasePath := filepath.Join("testcases", f.Name())
configFilename := filepath.Join(testcasePath, "telegraf.conf")
inputFilename := filepath.Join(testcasePath, "input.txt")
expectedFilename := filepath.Join(testcasePath, "expected.out")
expectedErrorFilename := filepath.Join(testcasePath, "expected.err")
// Prepare the influx parser for expectations
parser := &influx.Parser{}
require.NoError(t, parser.Init())
// Read the input data
inputData, err := os.ReadFile(inputFilename)
require.NoError(t, err)
// Read the expected output if any
var expected []telegraf.Metric
if _, err := os.Stat(expectedFilename); err == nil {
var err error
expected, err = testutil.ParseMetricsFromFile(expectedFilename, parser)
require.NoError(t, err)
}
// Read the expected error if any
var expectedError string
if _, err := os.Stat(expectedErrorFilename); err == nil {
buf, err := os.ReadFile(expectedErrorFilename)
require.NoError(t, err)
require.NotEmpty(t, buf)
expectedError = string(buf)
}
// Configure the plugin and start it
cfg := config.NewConfig()
require.NoError(t, cfg.LoadConfig(configFilename))
require.Len(t, cfg.Inputs, 1)
plugin := cfg.Inputs[0].Input.(*Syslog)
// Replace the TLS config with the known PKI infrastructure
if plugin.ServerConfig.TLSCert != "" {
plugin.ServerConfig = *pki.TLSServerConfig()
}
// Determine server properties. We need to parse the address before
// calling Start() as it is modified in this function.
u, err := url.Parse(plugin.Address)
require.NoError(t, err)
if u.Scheme == "unix" {
// Use a random socket
sock := testutil.TempSocket(t)
plugin.Address = "unix://" + sock
}
var acc testutil.Accumulator
require.NoError(t, plugin.Start(&acc))
defer plugin.Stop()
// Get the address
var addr string
if plugin.isStream {
addr = plugin.tcpListener.Addr().String()
} else {
addr = plugin.udpListener.LocalAddr().String()
}
// Create a fake sender
var client net.Conn
if srvTLS, _ := plugin.TLSConfig(); srvTLS != nil {
tlscfg, err := pki.TLSClientConfig().TLSConfig()
require.NoError(t, err)
tlscfg.ServerName = "localhost"
client, err = tls.Dial(u.Scheme, addr, tlscfg)
require.NoError(t, err)
} else {
client, err = net.Dial(u.Scheme, addr)
require.NoError(t, err)
}
defer client.Close()
// Send the data and afterwards stop client and plugin
_, err = client.Write(inputData)
require.NoError(t, err)
client.Close()
// Check the metric nevertheless as we might get some metrics despite errors.
require.Eventually(t, func() bool {
return int(acc.NMetrics()) >= len(expected)
}, 3*time.Second, 100*time.Millisecond)
plugin.Stop()
actual := acc.GetTelegrafMetrics()
testutil.RequireMetricsEqual(t, expected, actual, testutil.IgnoreTime())
// Check for errors
if expectedError != "" {
require.NotEmpty(t, acc.Errors)
var found bool
for _, err := range acc.Errors {
found = found || strings.Contains(err.Error(), expectedError)
}
require.Truef(t, found, "expected error %q not found in errors %v", expectedError, acc.Errors)
} else {
require.Empty(t, acc.Errors)
}
})
}
}

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
best_effort = true

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1,2 @@
<1>2 - - - - - -
<4>11 - - - - - -

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
best_effort = true

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,5 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
best_effort = true
tls_cert = "dummy.cert"

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1,2 @@
<1>2 - - - - - -
<4>11 - - - - - -

View File

@ -0,0 +1,5 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
best_effort = true
tls_cert = "dummy.cert"

View File

@ -0,0 +1 @@
unexpected EOF

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
framing = "non-transparent"
best_effort = true

View File

@ -0,0 +1 @@
unexpected EOF

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,5 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
framing = "non-transparent"
best_effort = true
tls_cert = "dummy.cert"

View File

@ -0,0 +1 @@
unexpected EOF

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1,2 @@
<1>2 - - - - - -
<4>11 - - - - - -

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
tls_cert = "dummy.cert"

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1,2 @@
<1>2 - - - - - -
<4>11 - - - - - -

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
framing = "non-transparent"
tls_cert = "dummy.cert"

View File

@ -0,0 +1 @@
unexpected EOF

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
framing = "non-transparent"

View File

@ -0,0 +1 @@
unexpected EOF

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
<29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
framing = "non-transparent"
tls_cert = "dummy.cert"

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=1u 0

View File

@ -0,0 +1 @@
16 <1>1 - - - - - -

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1 @@
16 <1>2 - - - - - -17 <4>11 - - - - - -

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,message="hello\nworld",severity_code=1i,version=3u 0

View File

@ -0,0 +1,2 @@
28 <1>3 - - - - - - hello
world

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
expecting a RFC3339MICRO timestamp or a nil value

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=217u 0

View File

@ -0,0 +1 @@
16 <1>217 <11>1 - - - - - -

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
parsing error [col 4]

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,message="hellø",severity_code=1i,version=1u 0

View File

@ -0,0 +1 @@
23 <1>1 - - - - - - hellø

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
best_effort = true

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"
tls_cert = "dummy.cert"
best_effort = true

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,3 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
best_effort = true

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,4 @@
[[inputs.syslog]]
server = "unix:///some/random/socket"
tls_cert = "dummy.cert"
best_effort = true

View File

@ -0,0 +1 @@
syslog,appname=someservice,facility=daemon,hostname=web1,severity=notice,source=127.0.0.1 facility_code=3i,message="\"GET /v1/ok HTTP/1.1\" 200 145 \"-\" \"hacheck 0.9.0\" 24306 127.0.0.1:40124 575",meta_sequence="14125553",meta_service="someservice",msgid="2",origin=true,procid="2341",severity_code=5i,timestamp=1456029177000000000i,version=1u 0

View File

@ -0,0 +1 @@
188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575

View File

@ -0,0 +1,2 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=1u 0

View File

@ -0,0 +1 @@
16 <1>1 - - - - - -

View File

@ -0,0 +1,2 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"

View File

@ -0,0 +1,2 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,severity_code=1i,version=2u 0
syslog,facility=kern,severity=warning,source=127.0.0.1 facility_code=0i,severity_code=4i,version=11u 1

View File

@ -0,0 +1 @@
16 <1>2 - - - - - -17 <4>11 - - - - - -

View File

@ -0,0 +1,2 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"

View File

@ -0,0 +1 @@
syslog,facility=kern,severity=alert,source=127.0.0.1 facility_code=0i,message="hello\nworld",severity_code=1i,version=3u 0

View File

@ -0,0 +1,2 @@
28 <1>3 - - - - - - hello
world

View File

@ -0,0 +1,2 @@
[[inputs.syslog]]
server = "tcp://127.0.0.1:0"

Some files were not shown because too many files have changed in this diff Show More