Created
February 22, 2017 09:02
-
-
Save gpolaert/4bbf38abfded708c092c2efaf47ba16c to your computer and use it in GitHub Desktop.
How to extend Elastic beats outputs by adding a plugin
This file contains hidden or 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
| package logmatic | |
| import ( | |
| "github.com/elastic/beats/libbeat/common" | |
| "github.com/elastic/beats/libbeat/common/op" | |
| "github.com/elastic/beats/libbeat/outputs" | |
| "os" | |
| ) | |
| func init() { | |
| outputs.RegisterOutputPlugin("logmatic", New) | |
| } | |
| type console struct { | |
| out *os.File | |
| codec outputs.Codec | |
| } | |
| func New(_ common.BeatInfo, _ *common.Config, _ int) (outputs.Outputer, error) { | |
| c := &console{} | |
| return c, nil | |
| } | |
| // Implement Outputer | |
| func (c *console) Close() error { | |
| return nil | |
| } | |
| func (c *console) PublishEvent(s op.Signaler, opts outputs.Options, data outputs.Data, ) error { | |
| return nil | |
| } |
This file contains hidden or 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
| package main | |
| import ( | |
| "os" | |
| _ "github.com/logmatic/walter/libbeat/outputs/logmatic" | |
| "github.com/elastic/beats/filebeat/beater" | |
| "github.com/elastic/beats/libbeat/beat" | |
| ) | |
| var Name = "filebeat" | |
| func main() { | |
| if err := beat.Run(Name, "", beater.New); err != nil { | |
| os.Exit(1) | |
| } | |
| } |
This file contains hidden or 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
| func RegisterOutputPlugin(name string, builder OutputBuilder) { | |
| outputsPlugins[name] = builder | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment