-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from ahadas/syslog
Forwarding to external syslog, based on current fluentd plugin
- Loading branch information
Showing
12 changed files
with
325 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
pkg/generators/forwarding/fluentd/output_conf_syslog_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package fluentd | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
logging "github.com/openshift/cluster-logging-operator/pkg/apis/logging/v1alpha1" | ||
test "github.com/openshift/cluster-logging-operator/test" | ||
) | ||
|
||
var _ = Describe("Generating external syslog server output store config blocks", func() { | ||
|
||
var ( | ||
err error | ||
outputs []logging.OutputSpec | ||
generator *ConfigGenerator | ||
) | ||
BeforeEach(func() { | ||
generator, err = NewConfigGenerator(false, false) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
Context("based on syslog plugin", func() { | ||
tcpConf := `<label @SYSLOG_RECEIVER> | ||
<match **> | ||
@type copy | ||
<store> | ||
@type syslog_buffered | ||
@id syslog_receiver | ||
remote_syslog sl.svc.messaging.cluster.local | ||
port 9654 | ||
hostname ${hostname} | ||
facility user | ||
severity debug | ||
</store> | ||
</match> | ||
</label>` | ||
|
||
udpConf := `<label @SYSLOG_RECEIVER> | ||
<match **> | ||
@type copy | ||
<store> | ||
@type syslog | ||
@id syslog_receiver | ||
remote_syslog sl.svc.messaging.cluster.local | ||
port 9654 | ||
hostname ${hostname} | ||
facility user | ||
severity debug | ||
</store> | ||
</match> | ||
</label>` | ||
|
||
Context("for protocol-less endpoint", func() { | ||
BeforeEach(func() { | ||
outputs = []logging.OutputSpec{ | ||
{ | ||
Type: logging.OutputTypeSyslog, | ||
Name: "syslog-receiver", | ||
Endpoint: "sl.svc.messaging.cluster.local:9654", | ||
}, | ||
} | ||
}) | ||
It("should produce well formed output label config", func() { | ||
results, err := generator.generateOutputLabelBlocks(outputs) | ||
Expect(err).To(BeNil()) | ||
Expect(len(results)).To(Equal(1)) | ||
test.Expect(results[0]).ToEqual(tcpConf) | ||
}) | ||
}) | ||
|
||
Context("for tcp endpoint", func() { | ||
BeforeEach(func() { | ||
outputs = []logging.OutputSpec{ | ||
{ | ||
Type: logging.OutputTypeSyslog, | ||
Name: "syslog-receiver", | ||
Endpoint: "tcp://sl.svc.messaging.cluster.local:9654", | ||
}, | ||
} | ||
}) | ||
It("should produce well formed output label config", func() { | ||
results, err := generator.generateOutputLabelBlocks(outputs) | ||
Expect(err).To(BeNil()) | ||
Expect(len(results)).To(Equal(1)) | ||
test.Expect(results[0]).ToEqual(tcpConf) | ||
}) | ||
}) | ||
|
||
Context("for udp endpoint", func() { | ||
BeforeEach(func() { | ||
outputs = []logging.OutputSpec{ | ||
{ | ||
Type: logging.OutputTypeSyslog, | ||
Name: "syslog-receiver", | ||
Endpoint: "udp://sl.svc.messaging.cluster.local:9654", | ||
}, | ||
} | ||
}) | ||
It("should produce well formed output label config", func() { | ||
results, err := generator.generateOutputLabelBlocks(outputs) | ||
Expect(err).To(BeNil()) | ||
Expect(len(results)).To(Equal(1)) | ||
test.Expect(results[0]).ToEqual(udpConf) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fluentd | ||
|
||
func (conf *outputLabelConf) SyslogPlugin() string { | ||
if protocol := conf.Protocol(); protocol == "udp" { | ||
return "syslog" | ||
} | ||
return "syslog_buffered" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.