-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
base: master
Are you sure you want to change the base?
Conversation
core/log.go
Outdated
payload := fmt.Sprintf(session.Config.Logstash, text) | ||
pc, err := net.ListenPacket("udp4", ":" + session.Config.LogstashPort) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
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.
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.