I have several custom beats that I am now refactoring to adopt the beats/v7 and go modules.
The trivial main.go no longer compile as there are breaking changes and the new API replacement is unclear how to use it.
The change is the RootCmd variable no longer exists:
See: https://github.com/elastic/beats/pull/15853
See: https://github.com/elastic/beats/blob/master/filebeat/cmd/root.go
Here is my original code ( filebeat variant that includes my custom regexprocessor:
package main
import (
"github.com/elastic/beats/filebeat/cmd"
_ "githubdev.dco.elmae/CloudPlatform/em-top-beats/maventbeat/regexprocessor"
"log"
"os"
)
func main() {
if err := cmd.RootCmd.Execute(); err != nil {
log.Printf("Error: %v\n", err)
os.Exit(1)
}
}
There is a public API that takes abeater.PluginFactory parameter that I’m unsure how to set it so as to maintain compatibility.
I tried passing nil and it compiles and runs but it does not process events correctly.
rootCmd := cmd.GenRootCmdWithSettings(beater.New(nil), instance.Settings{Name: "filebeat"})
func Filebeat(inputs beater.PluginFactory) *cmd.BeatsRootCmd {
What is the recipe for refactoring my code, specifically passing in beater.PluginFactory ?