# Adopting beats/v7 v7.8.1 - custom beat no longer compiles, refactoring help needed

**URL:** <https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 7, 2020, 4:22pm UTC](https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200 "2020-08-07T16:22:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmauri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmauri/32/56626_2.png) [@rmauri](https://discuss.elastic.co/u/rmauri)\
**Post date:** [August 7, 2020, 4:22pm UTC](https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200/1 "2020-08-07T16:22:26Z")

</div>

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](https://github.com/elastic/beats/pull/15853)  
See: [https://github.com/elastic/beats/blob/master/filebeat/cmd/root.go](https://github.com/elastic/beats/blob/master/filebeat/cmd/root.go)

Here is my original code ( filebeat variant that includes my custom regexprocessor:

```auto
    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 ?

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [August 11, 2020, 2:34pm UTC](https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200/2 "2020-08-11T14:34:06Z")

</div>

Is your Beat based on Filebeat? Or is it a custom generated Beat?

---

<div class="post-metadata">

**Author:** ![rmauri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmauri/32/56626_2.png) [@rmauri](https://discuss.elastic.co/u/rmauri)\
**Post date:** [August 14, 2020, 2:03pm UTC](https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200/3 "2020-08-14T14:03:22Z")

</div>

HI. It is a customized filebeat so I can add a custom regexprocessor.  
One day, I may add a PR to get regexprocessor contributed to beats.  
I found the solution was to do like the code for filebeat main.go

Thanks for helping get beats using go modules.  
I was able to ditch all the vendor folders after refactoring.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2020, 4:03pm UTC](https://discuss.elastic.co/t/adopting-beats-v7-v7-8-1-custom-beat-no-longer-compiles-refactoring-help-needed/244200/4 "2020-09-11T16:03:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
