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

[WIP] Add a Syslog input listening to UDP and TCP connection #6433

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
more stuff forward
  • Loading branch information
ph committed Feb 21, 2018
commit 32f40f8b6d814a73091b0ac4364c13ba3834c1cf
4 changes: 4 additions & 0 deletions filebeat/input/syslog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ var defaultUDPConfig = udpConfig{
MaxMessageSize: 10240,
Host: "localhost:8080",
}

func (c *config) isUDP() bool {
return strings.Upper(c.Protocol) == "UDP"
}
17 changes: 14 additions & 3 deletions filebeat/input/syslog/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ func NewInput(
return nil, err
}

config := defaultConfig
if err = cfg.Unpack(&config); err != nil {
return nil, err
}

forwarder := harvester.NewForwarder(out)
return &Input{
outlet: out,
harvester: NewHarvester(nil, cfg),
harvester: factory(config, forwarder),
started: false,
}
}
Expand All @@ -61,13 +66,19 @@ func (p *Input) Run() {
}
}

// Stop stops the UDP input
// Stop stops the TCP input
func (p *Input) Stop() {
logp.Info("stopping Syslog input")
p.harvester.Stop()
}

// Wait suspends the UDP input
// Wait suspends the TCP input
func (p *Input) Wait() {
p.Stop()
}

func factory(forwarder *harvester.Forwarder, config *Config) *harvester.Harvester {
if config.isUDP() {
havester.NewHarvester(forwarder, config)
}
}