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

Added UDP Output to be consumed by Logstash #45

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

blcarlson01
Copy link

This adds support for UDP output that can be consumed, processed, and forwarded by Logstash to ElasticSearch. Additionally, there is a sample dashboard that I have included.

This should be a step towards completing #37 enhancement request.

I'm new to Golang so feedback is much appreciated.

core/log.go Outdated
payload := fmt.Sprintf(session.Config.Logstash, text)
pc, err := net.ListenPacket("udp4", ":" + session.Config.LogstashPort)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should panic out "just" because the logstash session has an error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, I can get those removed and pushed to the branch.

core/log.go Outdated

addr,err := net.ResolveUDPAddr("udp4", session.Config.Logstash)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also not panic because of a logstash connection


addr, err := net.ResolveUDPAddr("udp4", session.Config.Logstash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test that? It seems like err is defined but never used and might give an error when compiling

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly no, because I had a couple of minutes so I just made the change and fatally assumed it would be fine. Is there a preferred way you want the err message to be handled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
addr, err := net.ResolveUDPAddr("udp4", session.Config.Logstash)
addr, err := net.ResolveUDPAddr("udp4", session.Config.Logstash)
if err != nil {
log.Error("Some meaningful message")
}


addr, err := net.ResolveUDPAddr("udp4", session.Config.Logstash)
if err != nil {
fmt.Printf("Logstash: No Such Host\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that if you just Printf the error, it will not have a log level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants