From 8373666e939a263db7c75eb3f39610142642cf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Fri, 5 Nov 2021 16:08:35 +0100 Subject: [PATCH] Remove Beat generators (#28816) From 8.0.0, we no longer support building custom Beats. This removes the documentation and the code as well. If someone wants to build their custom Beats, they still can based on 7.16. (cherry picked from commit c0f42bd1aa281399836abd73eef12a60d5be7938) --- CHANGELOG-developer.next.asciidoc | 2 + Jenkinsfile.yml | 2 - dev-tools/mage/fmt.go | 11 +- docs/devguide/contributing.asciidoc | 11 - docs/devguide/create-metricset.asciidoc | 3 +- .../creating-beat-from-metricbeat.asciidoc | 95 ---- docs/devguide/index.asciidoc | 2 - docs/devguide/metricbeat-devguide.asciidoc | 3 - docs/devguide/newbeat.asciidoc | 529 ------------------ generator/Jenkinsfile.yml | 49 -- generator/Makefile | 11 - generator/_templates/beat/.gitignore | 2 - generator/_templates/beat/CHANGELOG.md | 24 - generator/_templates/beat/Makefile | 1 - generator/_templates/beat/README.md | 3 - .../_templates/beat/{beat}/.editorconfig | 27 - generator/_templates/beat/{beat}/.gitignore | 7 - .../_templates/beat/{beat}/CONTRIBUTING.md | 0 generator/_templates/beat/{beat}/LICENSE.txt | 13 - generator/_templates/beat/{beat}/Makefile | 20 - generator/_templates/beat/{beat}/NOTICE.txt | 5 - generator/_templates/beat/{beat}/README.md | 116 ---- .../{beat}/_meta/config/beat.docker.yml.tmpl | 2 - .../_meta/config/beat.reference.yml.tmpl | 7 - .../beat/{beat}/_meta/config/beat.yml.tmpl | 7 - .../_templates/beat/{beat}/_meta/fields.yml | 9 - .../_templates/beat/{beat}/beater/{beat}.go | 71 --- generator/_templates/beat/{beat}/cmd/root.go | 14 - .../_templates/beat/{beat}/config/config.go | 14 - .../beat/{beat}/config/config_test.go | 4 - .../beat/{beat}/docs/index.asciidoc | 5 - .../_templates/beat/{beat}/include/include.go | 1 - generator/_templates/beat/{beat}/magefile.go | 100 ---- generator/_templates/beat/{beat}/main.go | 15 - generator/_templates/beat/{beat}/main_test.go | 28 - generator/_templates/beat/{beat}/make.bat | 11 - .../{beat}/tests/system/config/{beat}.yml.j2 | 78 --- .../beat/{beat}/tests/system/requirements.txt | 0 .../beat/{beat}/tests/system/test_base.py | 19 - .../beat/{beat}/tests/system/{beat}.py | 12 - .../_templates/beat/{beat}/tools/tools.go | 18 - generator/_templates/metricbeat/.gitignore | 6 - generator/_templates/metricbeat/CHANGELOG.md | 19 - generator/_templates/metricbeat/LICENSE | 13 - generator/_templates/metricbeat/Makefile | 7 - generator/_templates/metricbeat/README.md | 5 - .../metricbeat/{beat}/.editorconfig | 27 - .../_templates/metricbeat/{beat}/.gitignore | 2 - .../metricbeat/{beat}/CONTRIBUTING.md | 0 .../_templates/metricbeat/{beat}/LICENSE.txt | 13 - .../_templates/metricbeat/{beat}/Makefile | 14 - .../_templates/metricbeat/{beat}/NOTICE.txt | 5 - .../_templates/metricbeat/{beat}/README.md | 78 --- .../{beat}/_meta/config/beat.docker.yml.tmpl | 4 - .../_meta/config/beat.reference.yml.tmpl | 54 -- .../{beat}/_meta/config/beat.yml.tmpl | 19 - .../metricbeat/{beat}/cmd/modules.go | 48 -- .../_templates/metricbeat/{beat}/cmd/root.go | 50 -- .../metricbeat/{beat}/include/include.go | 1 - .../_templates/metricbeat/{beat}/magefile.go | 137 ----- .../_templates/metricbeat/{beat}/main.go | 16 - .../_templates/metricbeat/{beat}/make.bat | 11 - .../metricbeat/{beat}/tools/tools.go | 18 - generator/common/Makefile | 53 -- generator/common/beatgen/beatgen.go | 238 -------- generator/common/beatgen/setup/creator.go | 88 --- generator/common/beatgen/setup/setup.go | 159 ------ heartbeat/magefile.go | 6 - magefile.go | 7 - x-pack/heartbeat/magefile.go | 6 - 70 files changed, 6 insertions(+), 2449 deletions(-) delete mode 100644 docs/devguide/creating-beat-from-metricbeat.asciidoc delete mode 100644 docs/devguide/newbeat.asciidoc delete mode 100644 generator/Jenkinsfile.yml delete mode 100644 generator/Makefile delete mode 100644 generator/_templates/beat/.gitignore delete mode 100644 generator/_templates/beat/CHANGELOG.md delete mode 100644 generator/_templates/beat/Makefile delete mode 100644 generator/_templates/beat/README.md delete mode 100644 generator/_templates/beat/{beat}/.editorconfig delete mode 100644 generator/_templates/beat/{beat}/.gitignore delete mode 100644 generator/_templates/beat/{beat}/CONTRIBUTING.md delete mode 100644 generator/_templates/beat/{beat}/LICENSE.txt delete mode 100644 generator/_templates/beat/{beat}/Makefile delete mode 100644 generator/_templates/beat/{beat}/NOTICE.txt delete mode 100644 generator/_templates/beat/{beat}/README.md delete mode 100644 generator/_templates/beat/{beat}/_meta/config/beat.docker.yml.tmpl delete mode 100644 generator/_templates/beat/{beat}/_meta/config/beat.reference.yml.tmpl delete mode 100644 generator/_templates/beat/{beat}/_meta/config/beat.yml.tmpl delete mode 100644 generator/_templates/beat/{beat}/_meta/fields.yml delete mode 100644 generator/_templates/beat/{beat}/beater/{beat}.go delete mode 100644 generator/_templates/beat/{beat}/cmd/root.go delete mode 100644 generator/_templates/beat/{beat}/config/config.go delete mode 100644 generator/_templates/beat/{beat}/config/config_test.go delete mode 100644 generator/_templates/beat/{beat}/docs/index.asciidoc delete mode 100644 generator/_templates/beat/{beat}/include/include.go delete mode 100644 generator/_templates/beat/{beat}/magefile.go delete mode 100644 generator/_templates/beat/{beat}/main.go delete mode 100644 generator/_templates/beat/{beat}/main_test.go delete mode 100644 generator/_templates/beat/{beat}/make.bat delete mode 100644 generator/_templates/beat/{beat}/tests/system/config/{beat}.yml.j2 delete mode 100644 generator/_templates/beat/{beat}/tests/system/requirements.txt delete mode 100644 generator/_templates/beat/{beat}/tests/system/test_base.py delete mode 100644 generator/_templates/beat/{beat}/tests/system/{beat}.py delete mode 100644 generator/_templates/beat/{beat}/tools/tools.go delete mode 100644 generator/_templates/metricbeat/.gitignore delete mode 100644 generator/_templates/metricbeat/CHANGELOG.md delete mode 100644 generator/_templates/metricbeat/LICENSE delete mode 100644 generator/_templates/metricbeat/Makefile delete mode 100644 generator/_templates/metricbeat/README.md delete mode 100644 generator/_templates/metricbeat/{beat}/.editorconfig delete mode 100644 generator/_templates/metricbeat/{beat}/.gitignore delete mode 100644 generator/_templates/metricbeat/{beat}/CONTRIBUTING.md delete mode 100644 generator/_templates/metricbeat/{beat}/LICENSE.txt delete mode 100644 generator/_templates/metricbeat/{beat}/Makefile delete mode 100644 generator/_templates/metricbeat/{beat}/NOTICE.txt delete mode 100644 generator/_templates/metricbeat/{beat}/README.md delete mode 100644 generator/_templates/metricbeat/{beat}/_meta/config/beat.docker.yml.tmpl delete mode 100644 generator/_templates/metricbeat/{beat}/_meta/config/beat.reference.yml.tmpl delete mode 100644 generator/_templates/metricbeat/{beat}/_meta/config/beat.yml.tmpl delete mode 100644 generator/_templates/metricbeat/{beat}/cmd/modules.go delete mode 100644 generator/_templates/metricbeat/{beat}/cmd/root.go delete mode 100644 generator/_templates/metricbeat/{beat}/include/include.go delete mode 100644 generator/_templates/metricbeat/{beat}/magefile.go delete mode 100644 generator/_templates/metricbeat/{beat}/main.go delete mode 100644 generator/_templates/metricbeat/{beat}/make.bat delete mode 100644 generator/_templates/metricbeat/{beat}/tools/tools.go delete mode 100644 generator/common/Makefile delete mode 100644 generator/common/beatgen/beatgen.go delete mode 100644 generator/common/beatgen/setup/creator.go delete mode 100644 generator/common/beatgen/setup/setup.go diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index d56d47d5877..485f4d4152f 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -56,6 +56,8 @@ The list below covers the major changes between 7.0.0-rc2 and master only. - Remove Metricbeat EventFetcher and EventsFetcher interface. Use the reporter interface instead. {pull}25093[25093] - Update Darwin build image to a debian 10 base that increases the MacOS SDK and minimum supported version used in build to 10.14. {issue}24193[24193] - Removed the `common.Float` type. {issue}28279[28279] {pull}28280[28280] {pull}28376[28376] +- Removed Beat generators. {pull}28816[28816] +- libbeat.logp package forces ECS compliant logs. Logs are JSON formatted. Options to enable ECS/JSON have been removed. {issue}15544[15544] {pull}28573[28573] ==== Bugfixes diff --git a/Jenkinsfile.yml b/Jenkinsfile.yml index 6fec9910e5d..52fd8b0e1b1 100644 --- a/Jenkinsfile.yml +++ b/Jenkinsfile.yml @@ -2,8 +2,6 @@ projects: - "auditbeat" - "deploy/kubernetes" - "filebeat" - # Skipping because they are failing, see https://github.com/elastic/beats/pull/28723 - #- "generator" - "heartbeat" - "libbeat" - "metricbeat" diff --git a/dev-tools/mage/fmt.go b/dev-tools/mage/fmt.go index ed034e3fc9a..c047cd8ce05 100644 --- a/dev-tools/mage/fmt.go +++ b/dev-tools/mage/fmt.go @@ -50,13 +50,10 @@ func Format() { mg.Deps(GoImports, PythonAutopep8) } -// GoImports executes goimports against all .go files in and below the CWD. It -// ignores vendor/ and generator/_templates/ directories. +// GoImports executes goimports against all .go files in and below the CWD. func GoImports() error { goFiles, err := FindFilesRecursive(func(path string, _ os.FileInfo) bool { - return filepath.Ext(path) == ".go" && - !strings.Contains(path, "vendor/") && - !strings.Contains(path, "generator/_templates/") + return filepath.Ext(path) == ".go" }) if err != nil { return err @@ -84,9 +81,7 @@ func GoImports() error { // ignores build/ directories. func PythonAutopep8() error { pyFiles, err := FindFilesRecursive(func(path string, _ os.FileInfo) bool { - return filepath.Ext(path) == ".py" && - !strings.Contains(path, "build/") && - !strings.Contains(path, "vendor/") + return filepath.Ext(path) == ".py" && !strings.Contains(path, "build/") }) if err != nil { return err diff --git a/docs/devguide/contributing.asciidoc b/docs/devguide/contributing.asciidoc index d266397a334..435eb10416b 100644 --- a/docs/devguide/contributing.asciidoc +++ b/docs/devguide/contributing.asciidoc @@ -35,17 +35,6 @@ In the pull request, describe what your changes do and mention any bugs/issues related to the pull request. Please also add a changelog entry to https://github.com/elastic/beats/blob/master/CHANGELOG.next.asciidoc[CHANGELOG.next.asciidoc]. -[float] -[[adding-new-beat]] -=== Adding a New Beat - -If you want to create a new Beat, please read <>. You don't need to -submit the code to this repository. Most new Beats start in their own repository -and just make use of the libbeat packages. After you have a working Beat that -you'd like to share with others, open a PR to add it to our list of -https://github.com/elastic/beats/blob/master/libbeat/docs/communitybeats.asciidoc[community -Beats]. - [float] [[setting-up-dev-environment]] === Setting Up Your Dev Environment diff --git a/docs/devguide/create-metricset.asciidoc b/docs/devguide/create-metricset.asciidoc index cbbe6d651df..a1540be2384 100644 --- a/docs/devguide/create-metricset.asciidoc +++ b/docs/devguide/create-metricset.asciidoc @@ -2,8 +2,7 @@ === Creating a Metricset A metricset is the part of a Metricbeat module that fetches and structures the -data from the remote service. Each module can have multiple metricsets. In this guide, you learn how to create your own metricset. If you want to create -your own Beat that uses Metricbeat as a library, see <>. +data from the remote service. Each module can have multiple metricsets. In this guide, you learn how to create your own metricset. When creating a metricset for the first time, it generally helps to look at the implementation of existing metricsets for inspiration. diff --git a/docs/devguide/creating-beat-from-metricbeat.asciidoc b/docs/devguide/creating-beat-from-metricbeat.asciidoc deleted file mode 100644 index aef9e24de94..00000000000 --- a/docs/devguide/creating-beat-from-metricbeat.asciidoc +++ /dev/null @@ -1,95 +0,0 @@ -[[creating-beat-from-metricbeat]] -=== Creating a Beat based on Metricbeat - -deprecated:[7.16.0] - -The metricset Beat generator enables you to create a Beat that uses Metricbeat as a library and has your -own metricsets. - -[float] -==== Requirements - -To create your own Beat, you must have Go {go-version} or later installed, and the `$GOPATH` -must be set up correctly. In addition, the following tools are required: - -* https://www.python.org/downloads/[python] -* https://docs.python.org/3/library/venv.html[python venv module] -* https://github.com/magefile/mage[mage] - -Python venv module is already included in the standard library. In Ubuntu/Debian -it requires additional support scripts that can be installed with the -`python3-venv` package: - -[source,bash] ----- -sudo apt-get install python3-venv ----- - -[float] -==== Step 1 - Get the metricbeat source code - -The first step is to get the metricbeat source code: - -[source,bash] ----- -go get github.com/elastic/beats/metricbeat ----- - -This will clone the beats repository into `GOPATH`. By default `go get` fetches the master branch. To build your beat -on a specific version of libbeat, check out the specific branch ({branch} in the example below): - -["source","sh",subs="attributes"] ----- -cd ${GOPATH}/src/github.com/elastic/beats -git checkout {branch} ----- - -Note: If you have multiple go paths use `${GOPATH%%:*}`instead of `${GOPATH}`. - -Now change to the directory where you want to create the beat. -This directory is normally located under `$GOPATH/src/github.com/{your-github-name}`. Inside this directory, run the command to create the beat. - - -[float] -==== Step 2 - Create the Beat - -Run the command from the root `beats` directory: - -[source,bash] ----- -NEWBEAT_TYPE=metricbeat mage GenerateCustomBeat ----- - -When prompted, enter the Beat name and path, along with an initial module and metricset name for your beat. For more details about creating a metricset, see the docs <>. - -After creating the Beat, change the directory to `$GOPATH/src/github.com/{your-github-name}/{beat}` - - -[float] -==== Step 3 - Build & Run - -To create a binary run the `make` command. This will create the binary in your beats directory. - -To run it, execute the binary. This will automatically load the default configuration which was generated by `make update`. - -[source,bash] ----- -./beatname -e -d "*" ----- - -This will run the beat with debug output enabled to the console to directly see what is happening. Stop the beat with `CTRL-C`. - -[float] -==== Step 4 - Package - -To create packages and binaries for different platforms, https://www.docker.com/[docker] is required. -The first step is to get the most recent packaging tools into your beat: - -[source,bash] ----- -make release ----- - -This will fetch the most recent packaging tools and start the packaging of your beat. This can take a little bit longer. - -For more details about creating a metricset, see the docs about <>. diff --git a/docs/devguide/index.asciidoc b/docs/devguide/index.asciidoc index 6cc701592f0..6810240121c 100644 --- a/docs/devguide/index.asciidoc +++ b/docs/devguide/index.asciidoc @@ -21,8 +21,6 @@ include::./contributing.asciidoc[] include::{libbeat-dir}/communitybeats.asciidoc[] -include::./newbeat.asciidoc[] - include::./fields-yml.asciidoc[] include::./event-conventions.asciidoc[] diff --git a/docs/devguide/metricbeat-devguide.asciidoc b/docs/devguide/metricbeat-devguide.asciidoc index b2a4a312fe9..265bef2b8dd 100644 --- a/docs/devguide/metricbeat-devguide.asciidoc +++ b/docs/devguide/metricbeat-devguide.asciidoc @@ -18,7 +18,6 @@ This following topics describe how to contribute to Metricbeat by adding metrics * <> * <> * <> -* <> * <> If you would like to contribute to Metricbeat or the Beats project, also see @@ -59,6 +58,4 @@ include::./metricset-details.asciidoc[] include::./create-module.asciidoc[] -include::./creating-beat-from-metricbeat.asciidoc[] - include::./faq.asciidoc[] diff --git a/docs/devguide/newbeat.asciidoc b/docs/devguide/newbeat.asciidoc deleted file mode 100644 index e5fc685a31d..00000000000 --- a/docs/devguide/newbeat.asciidoc +++ /dev/null @@ -1,529 +0,0 @@ -[[new-beat]] -== Creating a New Beat - -deprecated:[7.16.0] - -This guide walks you through the steps for creating a new Elastic Beat. The -Beats are a collection of lightweight daemons that collect operational data from -your servers and ship it to Elasticsearch or Logstash. The common parts for -all Beats are placed in the libbeat library, which contains packages for sending -data to Elasticsearch and Logstash, for configuration file handling, for signal -handling, for logging, and more. By using this common framework, you can ensure -that all Beats behave consistently and that they are easy to package and run -with common tools. - -In this guide, you learn how to use the Beat generator to create source code for -an example Beat called Countbeat. The Beat generator creates all the files required -for a working Beat. To create your own Beat, you modify the generated -files and implement the custom logic needed to collect the data you want to ship. - -The following topics describe how to build a new Beat: - -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -The following topic provide information about moving generated Beats to go modules: - -* <> - -[[newbeat-getting-ready]] -=== Getting Ready - -All Beats are written in http://golang.org/[Go], so having Go installed and knowing -the basics are prerequisites for understanding this guide. - -*Before you begin:* Set up your Go environment as described under -<> in <>. The minimum required -Go version is {go-version}. - -To build your Beat on a specific version of libbeat, check out the specific -branch ({branch} in the example below): - -["source","sh",subs="attributes"] ----- -cd ${GOPATH}/src/github.com/elastic/beats -git checkout {branch} ----- - -[[newbeat-overview]] -=== Overview - -At the high level, a simple Beat has two main components: - -* a component that collects the actual data, and -* a publisher that sends the data to the specified output, such as Elasticsearch or -Logstash. - -The publisher is already implemented in libbeat, so you typically only have to worry about the logic -specific to your Beat (the code that creates the event and sends it to the publisher). -Libbeat also offers common services like configuration management, logging, -daemonzing, and Windows service handling, and data processing modules. - -image::./images/beat_overview.png[Beat overview architecture] - -The event that you create is a JSON-like object (Go type `map[string]interface{}`) that -contains the collected data to send to the publisher. At a minimum, the event object -must contain a `@timestamp` field and a `type` field. Beyond -that, events can contain any additional fields, and they can be created as often -as necessary. - -The following example shows an event object in Lsbeat: - -[source,json] ----------------------------------------------------------------------- -{ - "@timestamp": "2016-07-13T21:33:58.355Z", - "beat": { - "hostname": "mar.local", - "name": "mar.local" - }, - "directory": false, - "filename": "winlogbeat.yml", - "filesize": 2895, - "modtime": "2016-07-13T20:56:21.000Z", - "path": "./vendor/github.com/elastic/beats/winlogbeat/winlogbeat.yml", - "type": "lsbeat" -} - -{ - "@timestamp": "2016-07-13T21:33:58.354Z", - "beat": { - "hostname": "mar.local", - "name": "mar.local" - }, - "directory": true, - "filename": "system", - "filesize": 238, - "modtime": "2016-07-13T20:56:21.000Z", - "path": "./vendor/github.com/elastic/beats/winlogbeat/tests/system", - "type": "lsbeat" -} ----------------------------------------------------------------------- - -Now that you have the big picture, let's dig into the code. - -[[newbeat-generate]] -=== Generating Your Beat - -To generate your own Beat, you use the Beat generator available in the beats repo on GitHub. If you haven't -downloaded the Beats source code yet, follow the instructions in <>. - -Before running the Beat generator, you must decide on a name for your Beat. The name should be one word with -the first letter capitalized. In our example, we use `Countbeat`. - -Now create a directory under $GOPATH for your repository and change to the new directory: - -[source,shell] --------------------- -mkdir ${GOPATH}/src/github.com/{user} --------------------- - -Run the mage script to generate the custom beat: - - -[source,shell] --------------------- -cd ${GOPATH}/src/github.com/elastic/beats -mage GenerateCustomBeat --------------------- - -The mage script will prompt you to enter information about your Beat. For the `project_name`, enter `Countbeat`. -For the `github_name`, enter your github id. The `beat` and `beat_path` are set to the correct values automatically (just press Enter to accept each default). For the `full_name`, enter your firstname and lastname. Finally, pick the revision of elastic/beats you would like to depend on. - -[source,shell] ---------- -Enter a project name [examplebeat]: Countbeat -Enter a github name [your-github-name]: {username} -Enter a beat path [github.com/{username}/countbeat]: -Enter a full name [Firstname Lastname]: {Full Name} -Enter the github.com/elastic/beats revision [master]: ---------- - -The Beat generator creates a directory called `countbeat` inside of your project folder (e.g. {project folder}/github.com/{github id}/countbeat). - -Please note that it is not possible to use revisions of Beats which does not support go modules. - -You now have a raw template of the Beat, but you still need to <>. - -[[setting-up-beat]] -=== Fetching Dependencies and Setting up the Beat - -First you need to install the following tools: - -* https://www.python.org/downloads/[Python] -* https://docs.python.org/3/library/venv.html[Python venv module] - -To fetch dependencies and set up the Beat, run: - -[source,shell] ---------- -cd ${GOPATH}/src/github.com/{user}/countbeat -make update ---------- - -The Beat now contains the basic config file, `countbeat.yml`, and template files. The Beat is "complete" in the sense -that you can compile and run it. However, to make it functionally complete, you need to add your custom logic (see <>), along with any additional configuration parameters that your Beat requires. - -[[compiling-and-running]] -=== Building and Running the Beat - -To compile the Beat, make sure you are in the Beat directory (`$GOPATH/src/github.com/{user}/countbeat`) and run: - -[source,shell] ---------- -mage build ---------- - -NOTE: we don't support the `-j` option for make at the moment. - -Running this command creates the binary called `countbeat` in `$GOPATH/src/github.com/{user}/countbeat`. - -Now run the Beat: - -[source,shell] ---------- -./countbeat -e -d "*" ---------- - -The command automatically loads the default config file, `countbeat.yml`, and sends debug output to the console. - -You can stop the Beat by pressing `Ctrl+C`. - -[[beater-interface]] -=== The Beater Interface - -Each Beat needs to implement the Beater interface defined in libbeat. - -[source,go] ----------------------------------------------------------------------- -// Beater is the interface that must be implemented by every Beat. A Beater -// provides the main Run-loop and a Stop method to break the Run-loop. -// Instantiation and Configuration is normally provided by a Beat-`Creator`. -// -// Once the beat is fully configured, the Run() method is invoked. The -// Run()-method implements the beat its run-loop. Once the Run()-method returns, -// the beat shuts down. -// -// The Stop() method is invoked the first time (and only the first time) a -// shutdown signal is received. The Stop()-method normally will stop the Run()-loop, -// such that the beat can gracefully shutdown. -type Beater interface { - // The main event loop. This method should block until signalled to stop by an - // invocation of the Stop() method. - Run(b *Beat) error - - // Stop is invoked to signal that the Run method should finish its execution. - // It will be invoked at most once. - Stop() -} ----------------------------------------------------------------------- - -To implement the Beater interface, you need to define a Beat object that -implements two methods: <> and <>. - -[source,go] --------------- -type Countbeat struct { - done chan struct{} <1> - config config.Config <2> - client publisher.Client <3> - - ... -} - -func (bt *Countbeat) Run(b *beat.Beat) error { - ... -} - - -func (bt *Countbeat) Stop() { - ... -} - --------------- - -By default, the Beat object contains the following: - -<1> `done`: Channel used by the `Run()` method to stop when the `Stop()` method is called. -<2> `config`: Configuration options for the Beat -<3> `client`: Publisher that takes care of sending the events to the - defined output. - -The `Beat` parameter received by the `Run` method contains data about the -Beat, such as the name, version, and common configuration options. - -Each Beat also needs to implement the <> function to create the Beat object. This means your -Beat should implement the following functions: - -[horizontal] -<>:: Creates the Beat object -<>:: Contains the main application loop that captures data -and sends it to the defined output using the publisher -<>:: Contains logic that is called when the Beat is signaled to stop - -When you run the Beat generator, it adds implementations for all these functions to the source code (see -`beater/countbeat.go`). You can modify these implementations, as required, for your Beat. - -We strongly recommend that you create a main package that contains only the main -method (see `main.go`). All your Beat-specific code should go in a separate folder and package. -This will allow other Beats to use the other parts of your Beat as a library, if -needed. - -NOTE: To be consistent with other Beats, you should append `beat` to your Beat name. - -Let's go through each of the methods in the `Beater` interface and look at a -sample implementation. - -[[new-function]] -==== New function - -The `New()` function receives the configuration options defined for the Beat and -creates a Beat object based on them. Here's the `New()` function that's generated in -`beater/countbeat.go` when you run the Beat generator: - -[source,go] ----------------------------------------------------------------------- -func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) { - config := config.DefaultConfig - if err := cfg.Unpack(&config); err != nil { - return nil, fmt.Errorf("Error reading config file: %v", err) - } - - bt := &Countbeat{ - done: make(chan struct{}), - config: config, - } - return bt, nil -} - ----------------------------------------------------------------------- - -Pointers are used to distinguish between when the setting is completely -missing from the configuration file and when it has a value that matches the -type's default value. - -The recommended way of handling the configuration (as shown in the code example) -is to create a `Config` structure with the configuration options and a `DefaultConfig` with -the default configuration options. - -When you use the Beat generator, the Go structures for a basic config are added to `config/config.go`: - -[source,go] ----------------------------------------------------------------------- -package config - -import "time" - -type Config struct { - Period time.Duration `config:"period"` -} - -var DefaultConfig = Config{ - Period: 1 * time.Second, -} - ----------------------------------------------------------------------- - - -This mirrors the config options that are defined in the config file, `countbeat.yml`. - -[source,yaml] ------------- -countbeat: - # Defines how often an event is sent to the output - period: 10s ------------- - - - `period`: Defines how often to send out events - -The config file is generated when you run `make update` to <>. The file contains -basic configuration information. To add configuration options to your Beat, you need to update the Go structures in -`config/config.go` and add the corresponding config options to `_meta/beat.yml`. - -For example, if you add a config option called `path` to the Go structures: - -[source,go] ----------------------------------------------------------------------- -type Config struct { - Period time.Duration `config:"period"` - Path string `config:"path"` -} - -var DefaultConfig = Config{ - Period: 1 * time.Second, - Path: ".", -} - ----------------------------------------------------------------------- - -You also need to add `path` to `_meta/beat.yml`: - -[source,yml] ----------------------------------------------------------------------- -countbeat: - period: 10s - path: "." ----------------------------------------------------------------------- - -After modifying `beat.yml`, run the following command to apply your updates: - -[source,shell] ----------------------------------------------------------------------- -make update ----------------------------------------------------------------------- - -[[run-method]] -==== Run Method - -The `Run` method contains your main application loop. - -[source,go] ----------------------------------------------------------------------- -func (bt *Countbeat) Run(b *beat.Beat) error { - logp.Info("countbeat is running! Hit CTRL-C to stop it.") - - bt.client = b.Publisher.Connect() - ticker := time.NewTicker(bt.config.Period) - counter := 1 - for { - select { - case <-bt.done: - return nil - case <-ticker.C: - } - - event := common.MapStr{ <1> - "@timestamp": common.Time(time.Now()), <2> - "type": b.Name, - "counter": counter, - } - bt.client.PublishEvent(event) <3> - logp.Info("Event sent") - counter++ - } -} ----------------------------------------------------------------------- -<1> Create the event object. -<2> Specify a `@timestamp` field of time `common.Time`. -<3> Use the publisher to send the event out to the defined output - -Inside the loop, the Beat sleeps for a configurable period of time and then -captures the required data and sends it to the publisher. The publisher client is available as part of the Beat object -through the `client` variable. - -The `event := common.MapStr{}` stores the event in a json format, and `bt.client.PublishEvent(event)` publishes data to Elasticsearch. -In the generated Beat, there are three fields in the event: @timestamp, type, and counter. - -When you add fields to the event object, you also need to add them to the `_meta/fields.yml` file: - -[source,yaml] ----------------------------------------------------------------------- -- key: countbeat - title: countbeat - description: - fields: - - name: counter - type: long - required: true - description: > - PLEASE UPDATE DOCUMENTATION ----------------------------------------------------------------------- - -Remember to run `make update` to apply your updates. - -For more information on defining field mappings in `_meta/fields.yml`, see <>. - -For more detail about naming the fields in an event, see <>. - -[[stop-method]] -==== Stop Method - -The `Stop` method is called when the Beat is signaled to stop, for -example through the SIGTERM signal on Unix systems or the service control -interface on Windows. This method simply closes the channel -which breaks the main loop. - -[source,go] ----------------------------------------------------------------------- -func (bt *Countbeat) Stop() { - bt.client.Close() - close(bt.done) -} ----------------------------------------------------------------------- - -==== The main Function - -If you follow the `Countbeat` model and put your Beat-specific code in its own type -that implements the `Beater` interface, the code from your main package is -very simple: - -[source,go] ----------------------------------------------------------------------- -package main - -import ( - "os" - - "github.com/elastic/beats/libbeat/beat" - "github.com/elastic/beats/libbeat/cmd" - "github.com/elastic/beats/libbeat/cmd/instance" - - "github.com/kimjmin/countbeat/beater" -) - -var RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: "countbeat"}) - -func main() { - if err := RootCmd.Execute(); err != nil { - os.Exit(1) - } -} ----------------------------------------------------------------------- - -[[newbeat-sharing]] -=== Sharing Your Beat with the Community - -When you're done with your new Beat, how about letting everyone know? Open -a pull request to add your link to the {beats-ref}/community-beats.html[Community Beats] list. - -[[newbeat-migrate-gomodules]] -=== Migrate existing Beat to go modules - -Get started by making sure the contents of the vendored beats folder is -pushed to a remote repository. Otherwise, go will overwrite the folder -with the selected revision of `github.com/elastic/beats`. - -The following command will initialize a new module in your repo. - -[source,shell] ----------------------------------------------------------------------- -go mod init ----------------------------------------------------------------------- - -Make sure to add the approprite `replace` directives from the `go.mod` file -of Beats: https://github.com/elastic/beats/tree/master/go.mod -Unfortunately, this workaround is needed to make sure your Beat can be compiled. - -To depend on the latest `master` of `github.com/elastic/beats` run the following command: - -[source,shell] ----------------------------------------------------------------------- -go get github.com/elastic/beats@master ----------------------------------------------------------------------- - -We suggest you read the following section to learn about maintaining dependencies -using go modules: -* https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies[How to upgrade and downgrade dependencies] - -Please note that it is your choice whether you put dependencies in the folder vendor or not. - -If you choose to abandon the vendor folder, you have to adjust the following things in your Beat: - -* add `devtools.CrossBuildMountModcache = true` to the `magefile.go` of your Beat -* modify the path to `ES_BEATS` in the `Makefile` so it points to the folder under the module cache (`go list -m -f '{{.Dir}}' $ES_BEATS_IMPORT_PATH`) diff --git a/generator/Jenkinsfile.yml b/generator/Jenkinsfile.yml deleted file mode 100644 index d89108a1d4f..00000000000 --- a/generator/Jenkinsfile.yml +++ /dev/null @@ -1,49 +0,0 @@ -when: - branches: true ## for all the branches - changeset: ## when PR contains any of those entries in the changeset - - "^generator/.*" - - "#generator/common/beatgen" ## special token regarding the project dependency - - "#metricbeat/beater" ## special token regarding the project dependency - - "@ci" ## special token regarding the changeset for the ci - - "@oss" ## special token regarding the changeset for the oss - comments: ## when PR comment contains any of those entries - - "/test generator" - labels: ## when PR labels matches any of those entries - - "generator" - parameters: ## when parameter was selected in the UI. - - "generator" - tags: true ## for all the tags -platform: "immutable && ubuntu-18" ## default label for all the stages -stages: - metricbeat-test: - make: "make -C generator/_templates/metricbeat test test-package" - stage: mandatory - beat-test: - make: "make -C generator/_templates/beat test test-package" - stage: mandatory - macos-metricbeat: - make: "make -C generator/_templates/metricbeat test" - platforms: ## override default label in this specific stage. - - "macosx&&x86_64" - when: ## Override the top-level when. - comments: - - "/test generator for macos" - labels: - - "macOS" - parameters: - - "macosTest" - tags: true ## for all the tags - stage: extended - macos-beat: - make: "make -C generator/_templates/beat test" - platforms: ## override default label in this specific stage. - - "macosx&&x86_64" - when: ## Override the top-level when. - comments: - - "/test generator for macos" - labels: - - "macOS" - parameters: - - "macosTest" - tags: true ## for all the tags - stage: extended diff --git a/generator/Makefile b/generator/Makefile deleted file mode 100644 index 6f0122cc360..00000000000 --- a/generator/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# Runs test build for the count metricset -.PHONY: test -test: - $(MAKE) -C _templates/beat test - $(MAKE) -C _templates/metricbeat test - -# Cleans up environment -.PHONY: clean -clean: - @$(MAKE) -C _templates/beat clean - @$(MAKE) -C _templates/metricbeat clean diff --git a/generator/_templates/beat/.gitignore b/generator/_templates/beat/.gitignore deleted file mode 100644 index 3130d5d7a88..00000000000 --- a/generator/_templates/beat/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Folders -build diff --git a/generator/_templates/beat/CHANGELOG.md b/generator/_templates/beat/CHANGELOG.md deleted file mode 100644 index 2805fef2390..00000000000 --- a/generator/_templates/beat/CHANGELOG.md +++ /dev/null @@ -1,24 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file based on the -[Keep a Changelog](http://keepachangelog.com/) Standard. - -## [Unreleased](...HEAD) -### Added -- Add dev-tools/packer to package the beat for all supported platforms - -### Changed -- Use ucfg.Unpack() instead of cfgfile.Read() in Beater.Config method. -- Rename `Configuration` variable in beat struct to `beatConfig` as generalization from @buehler. -- Update Golang dependency to 1.6.0 -- Make testing dependent on local version of beats - -### Backward Compatibility Breaks -- Remove dependency on cookiecutter - -- Renamed BEAT_DIR to BEAT_PATH. -- Renamed BEATNAME to BEAT_NAME. -- Community beats now required BEAT_URL for packaging. - -### Bugfixes - -### Deprecated diff --git a/generator/_templates/beat/Makefile b/generator/_templates/beat/Makefile deleted file mode 100644 index 7c476dc5f6e..00000000000 --- a/generator/_templates/beat/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../../common/Makefile diff --git a/generator/_templates/beat/README.md b/generator/_templates/beat/README.md deleted file mode 100644 index 03755e95f95..00000000000 --- a/generator/_templates/beat/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Creating your own Beat - -The Beat generator enables you to create your own Beat in a few steps. Follow the [developer guide](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html) on how to do it. diff --git a/generator/_templates/beat/{beat}/.editorconfig b/generator/_templates/beat/{beat}/.editorconfig deleted file mode 100644 index a92dc2185bd..00000000000 --- a/generator/_templates/beat/{beat}/.editorconfig +++ /dev/null @@ -1,27 +0,0 @@ -# See: http://editorconfig.org -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.json] -indent_size = 4 -indent_style = space - -[*.py] -indent_style = space -indent_size = 4 - -[*.yml] -indent_style = space -indent_size = 2 - -[Makefile] -indent_style = tab - -[Vagrantfile] -indent_size = 2 -indent_style = space diff --git a/generator/_templates/beat/{beat}/.gitignore b/generator/_templates/beat/{beat}/.gitignore deleted file mode 100644 index 3c32225685d..00000000000 --- a/generator/_templates/beat/{beat}/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/.idea -/build - -.DS_Store -/{beat} -/{beat}.test -*.pyc diff --git a/generator/_templates/beat/{beat}/CONTRIBUTING.md b/generator/_templates/beat/{beat}/CONTRIBUTING.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/generator/_templates/beat/{beat}/LICENSE.txt b/generator/_templates/beat/{beat}/LICENSE.txt deleted file mode 100644 index 3e5c88efac8..00000000000 --- a/generator/_templates/beat/{beat}/LICENSE.txt +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) {year} {full_name} - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/generator/_templates/beat/{beat}/Makefile b/generator/_templates/beat/{beat}/Makefile deleted file mode 100644 index 94fe4131503..00000000000 --- a/generator/_templates/beat/{beat}/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -BEAT_NAME={beat} -BEAT_PATH={beat_path} -BEAT_GOPATH=$(firstword $(subst :, ,${GOPATH})) -SYSTEM_TESTS=false -TEST_ENVIRONMENT=false -ES_BEATS_IMPORT_PATH=github.com/elastic/beats/v7 -ES_BEATS?=$(shell go list -m -f '{{.Dir}}' ${ES_BEATS_IMPORT_PATH}) -LIBBEAT_MAKEFILE=$(ES_BEATS)/libbeat/scripts/Makefile -GOPACKAGES=$(shell go list ${BEAT_PATH}/... | grep -v /tools) -GOBUILD_FLAGS=-i -ldflags "-X ${ES_BEATS_IMPORT_PATH}/libbeat/version.buildTime=$(NOW) -X ${ES_BEATS_IMPORT_PATH}/libbeat/version.commit=$(COMMIT_ID)" -MAGE_IMPORT_PATH=github.com/magefile/mage -NO_COLLECT=true -CHECK_HEADERS_DISABLED=true - -# Path to the libbeat Makefile --include $(LIBBEAT_MAKEFILE) - -.PHONY: copy-vendor -copy-vendor: - mage vendorUpdate diff --git a/generator/_templates/beat/{beat}/NOTICE.txt b/generator/_templates/beat/{beat}/NOTICE.txt deleted file mode 100644 index b10d905153e..00000000000 --- a/generator/_templates/beat/{beat}/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -{beat} -Copyright {year} {full_name} - -This product includes software developed by The Apache Software -Foundation (http://www.apache.org/). diff --git a/generator/_templates/beat/{beat}/README.md b/generator/_templates/beat/{beat}/README.md deleted file mode 100644 index 7396c5edd80..00000000000 --- a/generator/_templates/beat/{beat}/README.md +++ /dev/null @@ -1,116 +0,0 @@ -# {Beat} - -Welcome to {Beat}. - -Ensure that this folder is at the following location: -`${GOPATH}/src/{beat_path}` - -## Getting Started with {Beat} - -### Requirements - -* [Golang](https://golang.org/dl/) 1.7 - -### Init Project -To get running with {Beat} and also install the -dependencies, run the following command: - -``` -make update -``` - -It will create a clean git history for each major step. Note that you can always rewrite the history if you wish before pushing your changes. - -To push {Beat} in the git repository, run the following commands: - -``` -git remote set-url origin https://{beat_path} -git push origin master -``` - -For further development, check out the [beat developer guide](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html). - -### Build - -To build the binary for {Beat} run the command below. This will generate a binary -in the same directory with the name {beat}. - -``` -make -``` - - -### Run - -To run {Beat} with debugging output enabled, run: - -``` -./{beat} -c {beat}.yml -e -d "*" -``` - - -### Test - -To test {Beat}, run the following command: - -``` -make testsuite -``` - -alternatively: -``` -make unit-tests -make system-tests -make integration-tests -make coverage-report -``` - -The test coverage is reported in the folder `./build/coverage/` - -### Update - -Each beat has a template for the mapping in elasticsearch and a documentation for the fields -which is automatically generated based on `fields.yml` by running the following command. - -``` -make update -``` - - -### Cleanup - -To clean {Beat} source code, run the following command: - -``` -make fmt -``` - -To clean up the build directory and generated artifacts, run: - -``` -make clean -``` - - -### Clone - -To clone {Beat} from the git repository, run the following commands: - -``` -mkdir -p ${GOPATH}/src/{beat_path} -git clone https://{beat_path} ${GOPATH}/src/{beat_path} -``` - - -For further development, check out the [beat developer guide](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html). - - -## Packaging - -The beat frameworks provides tools to crosscompile and package your beat for different platforms. This requires [docker](https://www.docker.com/) and vendoring as described above. To build packages of your beat, run the following command: - -``` -make release -``` - -This will fetch and create all images required for the build process. The whole process to finish can take several minutes. diff --git a/generator/_templates/beat/{beat}/_meta/config/beat.docker.yml.tmpl b/generator/_templates/beat/{beat}/_meta/config/beat.docker.yml.tmpl deleted file mode 100644 index 665509ac566..00000000000 --- a/generator/_templates/beat/{beat}/_meta/config/beat.docker.yml.tmpl +++ /dev/null @@ -1,2 +0,0 @@ -{beat}: - period: 1s diff --git a/generator/_templates/beat/{beat}/_meta/config/beat.reference.yml.tmpl b/generator/_templates/beat/{beat}/_meta/config/beat.reference.yml.tmpl deleted file mode 100644 index 7d9bb3942c3..00000000000 --- a/generator/_templates/beat/{beat}/_meta/config/beat.reference.yml.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -################### {Beat} Configuration Example ######################### - -############################# {Beat} ###################################### - -{beat}: - # Defines how often an event is sent to the output - period: 1s diff --git a/generator/_templates/beat/{beat}/_meta/config/beat.yml.tmpl b/generator/_templates/beat/{beat}/_meta/config/beat.yml.tmpl deleted file mode 100644 index 7d9bb3942c3..00000000000 --- a/generator/_templates/beat/{beat}/_meta/config/beat.yml.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -################### {Beat} Configuration Example ######################### - -############################# {Beat} ###################################### - -{beat}: - # Defines how often an event is sent to the output - period: 1s diff --git a/generator/_templates/beat/{beat}/_meta/fields.yml b/generator/_templates/beat/{beat}/_meta/fields.yml deleted file mode 100644 index a2ffb457d8a..00000000000 --- a/generator/_templates/beat/{beat}/_meta/fields.yml +++ /dev/null @@ -1,9 +0,0 @@ -- key: {beat} - title: {beat} - description: - fields: - - name: counter - type: long - required: true - description: > - PLEASE UPDATE DOCUMENTATION diff --git a/generator/_templates/beat/{beat}/beater/{beat}.go b/generator/_templates/beat/{beat}/beater/{beat}.go deleted file mode 100644 index 236c3d66390..00000000000 --- a/generator/_templates/beat/{beat}/beater/{beat}.go +++ /dev/null @@ -1,71 +0,0 @@ -package beater - -import ( - "fmt" - "time" - - "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/libbeat/common" - "github.com/elastic/beats/v7/libbeat/logp" - - "{beat_path}/config" -) - -// {beat} configuration. -type {beat} struct { - done chan struct{} - config config.Config - client beat.Client -} - -// New creates an instance of {beat}. -func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) { - c := config.DefaultConfig - if err := cfg.Unpack(&c); err != nil { - return nil, fmt.Errorf("Error reading config file: %v", err) - } - - bt := &{beat}{ - done: make(chan struct{}), - config: c, - } - return bt, nil -} - -// Run starts {beat}. -func (bt *{beat}) Run(b *beat.Beat) error { - logp.Info("{beat} is running! Hit CTRL-C to stop it.") - - var err error - bt.client, err = b.Publisher.Connect() - if err != nil { - return err - } - - ticker := time.NewTicker(bt.config.Period) - counter := 1 - for { - select { - case <-bt.done: - return nil - case <-ticker.C: - } - - event := beat.Event{ - Timestamp: time.Now(), - Fields: common.MapStr{ - "type": b.Info.Name, - "counter": counter, - }, - } - bt.client.Publish(event) - logp.Info("Event sent") - counter++ - } -} - -// Stop stops {beat}. -func (bt *{beat}) Stop() { - bt.client.Close() - close(bt.done) -} diff --git a/generator/_templates/beat/{beat}/cmd/root.go b/generator/_templates/beat/{beat}/cmd/root.go deleted file mode 100644 index 9607edb86a2..00000000000 --- a/generator/_templates/beat/{beat}/cmd/root.go +++ /dev/null @@ -1,14 +0,0 @@ -package cmd - -import ( - "{beat_path}/beater" - - cmd "github.com/elastic/beats/v7/libbeat/cmd" - "github.com/elastic/beats/v7/libbeat/cmd/instance" -) - -// Name of this beat -var Name = "{beat}" - -// RootCmd to handle beats cli -var RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name}) diff --git a/generator/_templates/beat/{beat}/config/config.go b/generator/_templates/beat/{beat}/config/config.go deleted file mode 100644 index a4ad302e994..00000000000 --- a/generator/_templates/beat/{beat}/config/config.go +++ /dev/null @@ -1,14 +0,0 @@ -// Config is put into a different package to prevent cyclic imports in case -// it is needed in several locations - -package config - -import "time" - -type Config struct { - Period time.Duration `config:"period"` -} - -var DefaultConfig = Config{ - Period: 1 * time.Second, -} diff --git a/generator/_templates/beat/{beat}/config/config_test.go b/generator/_templates/beat/{beat}/config/config_test.go deleted file mode 100644 index 8abe696e7e0..00000000000 --- a/generator/_templates/beat/{beat}/config/config_test.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build !integration -// +build !integration - -package config diff --git a/generator/_templates/beat/{beat}/docs/index.asciidoc b/generator/_templates/beat/{beat}/docs/index.asciidoc deleted file mode 100644 index 3475e7d069c..00000000000 --- a/generator/_templates/beat/{beat}/docs/index.asciidoc +++ /dev/null @@ -1,5 +0,0 @@ -= {Beat} Docs - -Welcome to the {Beat} documentation. - - diff --git a/generator/_templates/beat/{beat}/include/include.go b/generator/_templates/beat/{beat}/include/include.go deleted file mode 100644 index 8e731cdfc38..00000000000 --- a/generator/_templates/beat/{beat}/include/include.go +++ /dev/null @@ -1 +0,0 @@ -package include diff --git a/generator/_templates/beat/{beat}/magefile.go b/generator/_templates/beat/{beat}/magefile.go deleted file mode 100644 index 001e33ee255..00000000000 --- a/generator/_templates/beat/{beat}/magefile.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build mage -// +build mage - -package main - -import ( - "fmt" - "time" - - "github.com/magefile/mage/mg" - "github.com/magefile/mage/sh" - - devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/dev-tools/mage/target/build" - "github.com/elastic/beats/v7/dev-tools/mage/target/common" - "github.com/elastic/beats/v7/dev-tools/mage/target/pkg" - "github.com/elastic/beats/v7/dev-tools/mage/target/unittest" -) - -func init() { - devtools.SetBuildVariableSources(devtools.DefaultBeatBuildVariableSources) - - devtools.BeatDescription = "One sentence description of the Beat." - devtools.BeatVendor = "{full_name}" - devtools.BeatProjectType = devtools.CommunityProject - devtools.CrossBuildMountModcache = true -} - -// Package packages the Beat for distribution. -// Use SNAPSHOT=true to build snapshots. -// Use PLATFORMS to control the target platforms. -func Package() { - start := time.Now() - defer func() { fmt.Println("package ran for", time.Since(start)) }() - - devtools.UseCommunityBeatPackaging() - - mg.Deps(Update) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) - mg.SerialDeps(devtools.Package, pkg.PackageTest) -} - -// Update updates the generated files (aka make update). -func Update() error { - return sh.Run("make", "update") -} - -// Fields generates a fields.yml for the Beat. -func Fields() error { - return devtools.GenerateFieldsYAML() -} - -// Config generates both the short/reference/docker configs. -func Config() error { - p := devtools.DefaultConfigFileParams() - p.Templates = append(p.Templates, "_meta/config/*.tmpl") - return devtools.Config(devtools.AllConfigTypes, p, ".") -} - -// Clean cleans all generated files and build artifacts. -func Clean() error { - return devtools.Clean() -} - -// Check formats code, updates generated content, check for common errors, and -// checks for any modified files. -func Check() { - common.Check() -} - -// Fmt formats source code (.go and .py) and adds license headers. -func Fmt() { - common.Fmt() -} - -// Test runs all available tests -func Test() { - mg.Deps(unittest.GoUnitTest) -} - -// Build builds the Beat binary. -func Build() error { - return build.Build() -} - -// CrossBuild cross-builds the beat for all target platforms. -func CrossBuild() error { - return build.CrossBuild() -} - -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return build.BuildGoDaemon() -} - -// GolangCrossBuild build the Beat binary inside of the golang-builder. -// Do not use directly, use crossBuild instead. -func GolangCrossBuild() error { - return build.GolangCrossBuild() -} diff --git a/generator/_templates/beat/{beat}/main.go b/generator/_templates/beat/{beat}/main.go deleted file mode 100644 index d96fb2b8532..00000000000 --- a/generator/_templates/beat/{beat}/main.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "os" - - "{beat_path}/cmd" - - _ "{beat_path}/include" -) - -func main() { - if err := cmd.RootCmd.Execute(); err != nil { - os.Exit(1) - } -} diff --git a/generator/_templates/beat/{beat}/main_test.go b/generator/_templates/beat/{beat}/main_test.go deleted file mode 100644 index f56c7a1d8d8..00000000000 --- a/generator/_templates/beat/{beat}/main_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -// This file is mandatory as otherwise the {beat}.test binary is not generated correctly. - -import ( - "flag" - "testing" - - "{beat_path}/cmd" -) - -var systemTest *bool - -func init() { - testing.Init() - systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") - - cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) -} - -// Test started when the test binary is started. Only calls main. -func TestSystem(t *testing.T) { - - if *systemTest { - main() - } -} diff --git a/generator/_templates/beat/{beat}/make.bat b/generator/_templates/beat/{beat}/make.bat deleted file mode 100644 index 72de5798dfa..00000000000 --- a/generator/_templates/beat/{beat}/make.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -REM Windows wrapper for Mage (https://magefile.org/) that installs it -REM to %GOPATH%\bin from the Beats vendor directory. -REM -REM After running this once you may invoke mage.exe directly. - -WHERE mage -IF %ERRORLEVEL% NEQ 0 go install {beat_path}/vendor/github.com/magefile/mage - -mage %* diff --git a/generator/_templates/beat/{beat}/tests/system/config/{beat}.yml.j2 b/generator/_templates/beat/{beat}/tests/system/config/{beat}.yml.j2 deleted file mode 100644 index ece38d02c0d..00000000000 --- a/generator/_templates/beat/{beat}/tests/system/config/{beat}.yml.j2 +++ /dev/null @@ -1,78 +0,0 @@ -################### Beat Configuration ######################### - - - -############################# Output ########################################## - -# Configure what outputs to use when sending the data collected by the beat. -# You can enable one or multiple outputs by setting enabled option to true. -output: - - ### File as output - file: - # Enabling file output - enabled: true - - # Path to the directory where to save the generated files. The option is mandatory. - path: {{ output_file_path|default(beat.working_dir + "/output") }} - - - # Name of the generated files. The default is `{beat}` and it generates - # files: `{beat}`, `{beat}.1`, `{beat}.2`, etc. - filename: {{ output_file_filename|default("{beat}") }} - - # Maximum size in kilobytes of each file. When this size is reached, the files are - # rotated. The default value is 10 MB. - #rotate_every_kb: 10000 - - # Maximum number of files under path. When this number of files is reached, the - # oldest file is deleted and the rest are shifted from last to first. The default - # is 7 files. - #number_of_files: 7 - - - -############################# Beat ######################################### - -# The name of the shipper that publishes the network data. It can be used to group -# all the transactions sent by a single shipper in the web interface. -# If this options is not defined, the hostname is used. -#name: - -# The tags of the shipper are included in their own field with each -# transaction published. Tags make it easy to group servers by different -# logical properties. -#tags: ["service-X", "web-tier"] - - - -############################# Logging ######################################### - -#logging: - # Send all logging output to syslog. On Windows default is false, otherwise - # default is true. - #to_syslog: true - - # Write all logging output to files. Beats automatically rotate files if configurable - # limit is reached. - #to_files: false - - # Enable debug output for selected components. - #selectors: [] - - # Set log level - #level: error - - #files: - # The directory where the log files will written to. - #path: /var/log/{beat} - - # The name of the files where the logs are written to. - #name: {beat} - - # Configure log file size limit. If limit is reached, log file will be - # automatically rotated - #rotateeverybytes: 10485760 # = 10MB - - # Number of rotated log files to keep. Oldest files will be deleted first. - #keepfiles: 7 diff --git a/generator/_templates/beat/{beat}/tests/system/requirements.txt b/generator/_templates/beat/{beat}/tests/system/requirements.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/generator/_templates/beat/{beat}/tests/system/test_base.py b/generator/_templates/beat/{beat}/tests/system/test_base.py deleted file mode 100644 index 44e4e0ec7ca..00000000000 --- a/generator/_templates/beat/{beat}/tests/system/test_base.py +++ /dev/null @@ -1,19 +0,0 @@ -from {beat} import BaseTest - -import os - - -class Test(BaseTest): - - def test_base(self): - """ - Basic test with exiting {Beat} normally - """ - self.render_config_template( - path=os.path.abspath(self.working_dir) + "/log/*" - ) - - {beat}_proc = self.start_beat() - self.wait_until(lambda: self.log_contains("{beat} is running")) - exit_code = {beat}_proc.kill_and_wait() - assert exit_code == 0 diff --git a/generator/_templates/beat/{beat}/tests/system/{beat}.py b/generator/_templates/beat/{beat}/tests/system/{beat}.py deleted file mode 100644 index 9bd7453c6fd..00000000000 --- a/generator/_templates/beat/{beat}/tests/system/{beat}.py +++ /dev/null @@ -1,12 +0,0 @@ -import os -import sys -from beat.beat import TestCase - - -class BaseTest(TestCase): - - @classmethod - def setUpClass(self): - self.beat_name = "{beat}" - self.beat_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")) - super(BaseTest, self).setUpClass() diff --git a/generator/_templates/beat/{beat}/tools/tools.go b/generator/_templates/beat/{beat}/tools/tools.go deleted file mode 100644 index 1ddaba8a29d..00000000000 --- a/generator/_templates/beat/{beat}/tools/tools.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build tools -// +build tools - -// This package contains the tool dependencies of the project. - -package tools - -import ( - _ "github.com/blakesmith/ar" - _ "github.com/cavaliercoder/go-rpm" - _ "github.com/magefile/mage" - _ "github.com/mitchellh/gox" - _ "github.com/pierrre/gotestcover" - _ "github.com/tsg/go-daemon" - _ "golang.org/x/lint/golint" - _ "golang.org/x/tools/cmd/goimports" - _ "gotest.tools/gotestsum/cmd" -) diff --git a/generator/_templates/metricbeat/.gitignore b/generator/_templates/metricbeat/.gitignore deleted file mode 100644 index e7b756ffdf7..00000000000 --- a/generator/_templates/metricbeat/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# Directories -.idea -build - -# Files -.DS_Store \ No newline at end of file diff --git a/generator/_templates/metricbeat/CHANGELOG.md b/generator/_templates/metricbeat/CHANGELOG.md deleted file mode 100644 index 5ecaa98a5fb..00000000000 --- a/generator/_templates/metricbeat/CHANGELOG.md +++ /dev/null @@ -1,19 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file based on the -[Keep a Changelog](http://keepachangelog.com/) Standard. - -## [Unreleased](...HEAD) - -### Added - -### Changed - -### Backward Compatibility Breaks - -* Renamed BEAT_DIR to BEAT_PATH. -* Renamed BEAT_NAME to BEAT_NAME. -* Community beats now required BEAT_URL for packaging. - -### Bugfixes - -### Deprecated diff --git a/generator/_templates/metricbeat/LICENSE b/generator/_templates/metricbeat/LICENSE deleted file mode 100644 index 43976b73b2b..00000000000 --- a/generator/_templates/metricbeat/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2012–2016 Elasticsearch - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/generator/_templates/metricbeat/Makefile b/generator/_templates/metricbeat/Makefile deleted file mode 100644 index d58cf4922bb..00000000000 --- a/generator/_templates/metricbeat/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -BEAT_TYPE = metricbeat - -include ../../common/Makefile - -# Collects all dependencies and then calls update -.PHONY: collect -collect: diff --git a/generator/_templates/metricbeat/README.md b/generator/_templates/metricbeat/README.md deleted file mode 100644 index eb6d7582043..00000000000 --- a/generator/_templates/metricbeat/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Creating a Beat based on Metricbeat - -The metricset Beat generator enables you to create a Beat that uses Metricbeat as a library and has your -own metricsets. For more details on how to create your own metricbeat check out the [developer guide](https://www.elastic.co/guide/en/beats/devguide/current/creating-beat-from-metricbeat.html). - diff --git a/generator/_templates/metricbeat/{beat}/.editorconfig b/generator/_templates/metricbeat/{beat}/.editorconfig deleted file mode 100644 index a92dc2185bd..00000000000 --- a/generator/_templates/metricbeat/{beat}/.editorconfig +++ /dev/null @@ -1,27 +0,0 @@ -# See: http://editorconfig.org -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.json] -indent_size = 4 -indent_style = space - -[*.py] -indent_style = space -indent_size = 4 - -[*.yml] -indent_style = space -indent_size = 2 - -[Makefile] -indent_style = tab - -[Vagrantfile] -indent_size = 2 -indent_style = space diff --git a/generator/_templates/metricbeat/{beat}/.gitignore b/generator/_templates/metricbeat/{beat}/.gitignore deleted file mode 100644 index c7ecdee49ab..00000000000 --- a/generator/_templates/metricbeat/{beat}/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Directories -build diff --git a/generator/_templates/metricbeat/{beat}/CONTRIBUTING.md b/generator/_templates/metricbeat/{beat}/CONTRIBUTING.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/generator/_templates/metricbeat/{beat}/LICENSE.txt b/generator/_templates/metricbeat/{beat}/LICENSE.txt deleted file mode 100644 index 3e5c88efac8..00000000000 --- a/generator/_templates/metricbeat/{beat}/LICENSE.txt +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) {year} {full_name} - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/generator/_templates/metricbeat/{beat}/Makefile b/generator/_templates/metricbeat/{beat}/Makefile deleted file mode 100644 index ebdc51b72fb..00000000000 --- a/generator/_templates/metricbeat/{beat}/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -BEAT_NAME={beat} -BEAT_PATH={beat_path} -BEAT_GOPATH=$(firstword $(subst :, ,${GOPATH})) -SYSTEM_TESTS=false -TEST_ENVIRONMENT=false -ES_BEATS_IMPORT_PATH=github.com/elastic/beats/v7 -ES_BEATS?=$(shell go list -m -f '{{.Dir}}' ${ES_BEATS_IMPORT_PATH}) -GOPACKAGES=$(shell go list ${BEAT_PATH}/... | grep -v /tools) -GOBUILD_FLAGS=-i -ldflags "-X ${ES_BEATS_IMPORT_PATH}/libbeat/version.buildTime=$(NOW) -X ${ES_BEATS_IMPORT_PATH}/libbeat/version.commit=$(COMMIT_ID)" -MAGE_IMPORT_PATH=github.com/magefile/mage -CHECK_HEADERS_DISABLED=true - -# Path to the libbeat Makefile --include $(ES_BEATS)/metricbeat/Makefile diff --git a/generator/_templates/metricbeat/{beat}/NOTICE.txt b/generator/_templates/metricbeat/{beat}/NOTICE.txt deleted file mode 100644 index b10d905153e..00000000000 --- a/generator/_templates/metricbeat/{beat}/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -{beat} -Copyright {year} {full_name} - -This product includes software developed by The Apache Software -Foundation (http://www.apache.org/). diff --git a/generator/_templates/metricbeat/{beat}/README.md b/generator/_templates/metricbeat/{beat}/README.md deleted file mode 100644 index cc773977f83..00000000000 --- a/generator/_templates/metricbeat/{beat}/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# {project_name} - -{project_name} is a beat based on metricbeat which was generated with metricbeat/metricset generator. - - -## Getting started - -To get started run the following command. This command should only be run once. - -``` -make update -``` - -It will ask you for the module and metricset name. Insert the name accordingly. - -To compile your beat run `make`. Then you can run the following command to see the first output: - -``` -{beat} -e -d "*" -``` - -In case further modules are metricsets should be added, run: - -``` -make create-metricset -``` - -After updates to the fields or config files, always run - -``` -make collect -``` - -This updates all fields and docs with the most recent changes. - -## Dependency management - -Beats uses go modules for dependency management. - -In order to maintain your `vendor` folder, run `mage copyVendor`. - -This will create a directory `vendor` inside your repository. To make sure all dependencies for the Makefile commands are loaded from the vendor directory, find the following line in your Makefile: - -``` -ES_BEATS=${GOPATH}/src/github.com/elastic/beats -``` - -Replace it with: -``` -ES_BEATS=./vendor/github.com/elastic/beats/v7 -``` - - -## Versioning - -We recommend to version your repository with git and make it available on Github so others can also use your project. The initialise the git repository and add the first commits, you can use the following commands: - -``` -git init -git add README.md CONTRIBUTING.md -git commit -m "Initial commit" -git add LICENSE -git commit -m "Add the LICENSE" -git add .gitignore -git commit -m "Add git settings" -git add . -git commit -m "Add {beat}" -``` - -## Packaging - -The beat frameworks provides tools to crosscompile and package your beat for different platforms. This requires [docker](https://www.docker.com/) and vendoring as described above. To build packages of your beat, run the following command: - -``` -make release -``` - -This will fetch and create all images required for the build process. The hole process to finish can take several minutes. diff --git a/generator/_templates/metricbeat/{beat}/_meta/config/beat.docker.yml.tmpl b/generator/_templates/metricbeat/{beat}/_meta/config/beat.docker.yml.tmpl deleted file mode 100644 index 850b0dffab4..00000000000 --- a/generator/_templates/metricbeat/{beat}/_meta/config/beat.docker.yml.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -{{.BeatName}}.config.modules: - path: ${path.config}/modules.d/*.yml - reload.enabled: false - diff --git a/generator/_templates/metricbeat/{beat}/_meta/config/beat.reference.yml.tmpl b/generator/_templates/metricbeat/{beat}/_meta/config/beat.reference.yml.tmpl deleted file mode 100644 index 7416147455b..00000000000 --- a/generator/_templates/metricbeat/{beat}/_meta/config/beat.reference.yml.tmpl +++ /dev/null @@ -1,54 +0,0 @@ -########################## {{.BeatName}} Configuration ########################### - -# This file is a full configuration example documenting all non-deprecated -# options in comments. For a shorter configuration example, that contains only -# the most common options, please see metricbeat.yml in the same directory. -# -# You can find the full configuration reference here: -# https://www.elastic.co/guide/en/beats/metricbeat/index.html - -#============================ Config Reloading =============================== - -# Config reloading allows to dynamically load modules. Each file which is -# monitored must contain one or multiple modules as a list. -{{.BeatName}}.config.modules: - - # Glob pattern for configuration reloading - path: ${path.config}/modules.d/*.yml - - # Period on which files under path should be checked for changes - reload.period: 10s - - # Set to true to enable config reloading - reload.enabled: false - -# Maximum amount of time to randomly delay the start of a metricset. Use 0 to -# disable startup delay. -{{.BeatName}}.max_start_delay: 10s - -#============================== Autodiscover =================================== - -# Autodiscover allows you to detect changes in the system and spawn new modules -# as they happen. - -#{{.BeatName}}.autodiscover: - # List of enabled autodiscover providers -# providers: -# - type: docker -# templates: -# - condition: -# equals.docker.container.image: etcd -# config: -# - module: etcd -# metricsets: ["leader", "self", "store"] -# period: 10s -# hosts: ["${host}:2379"] - -#=========================== Timeseries instance =============================== - -# Enabling this will add a `timeseries.instance` keyword field to all metric -# events. For a given metricset, this field will be unique for every single item -# being monitored. -# This setting is experimental. - -#timeseries.enabled: false diff --git a/generator/_templates/metricbeat/{beat}/_meta/config/beat.yml.tmpl b/generator/_templates/metricbeat/{beat}/_meta/config/beat.yml.tmpl deleted file mode 100644 index e865163679a..00000000000 --- a/generator/_templates/metricbeat/{beat}/_meta/config/beat.yml.tmpl +++ /dev/null @@ -1,19 +0,0 @@ - -#========================== Modules configuration ============================ - -{{.BeatName}}.config.modules: - # Glob pattern for configuration loading - path: ${path.config}/modules.d/*.yml - - # Set to true to enable config reloading - reload.enabled: false - - # Period on which files under path should be checked for changes - #reload.period: 10s - -#==================== Elasticsearch template setting ========================== - -setup.template.settings: - index.number_of_shards: 1 - index.codec: best_compression - #_source.enabled: false diff --git a/generator/_templates/metricbeat/{beat}/cmd/modules.go b/generator/_templates/metricbeat/{beat}/cmd/modules.go deleted file mode 100644 index 411a9bdaeff..00000000000 --- a/generator/_templates/metricbeat/{beat}/cmd/modules.go +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package cmd - -import ( - "strings" - - "github.com/pkg/errors" - - "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/libbeat/cfgfile" - "github.com/elastic/beats/v7/libbeat/cmd" -) - -// BuildModulesManager adds support for modules management to a beat -func BuildModulesManager(beat *beat.Beat) (cmd.ModulesManager, error) { - config := beat.BeatConfig - - glob, err := config.String("config.modules.path", -1) - if err != nil { - return nil, errors.Errorf("modules management requires '%s.config.modules.path' setting", Name) - } - - if !strings.HasSuffix(glob, "*.yml") { - return nil, errors.Errorf("wrong settings for config.modules.path, it is expected to end with *.yml. Got: %s", glob) - } - - modulesManager, err := cfgfile.NewGlobManager(glob, ".yml", ".disabled") - if err != nil { - return nil, errors.Wrap(err, "initialization error") - } - return modulesManager, nil -} diff --git a/generator/_templates/metricbeat/{beat}/cmd/root.go b/generator/_templates/metricbeat/{beat}/cmd/root.go deleted file mode 100644 index 840e7b1a7cd..00000000000 --- a/generator/_templates/metricbeat/{beat}/cmd/root.go +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package cmd - -import ( - cmd "github.com/elastic/beats/v7/libbeat/cmd" - "github.com/elastic/beats/v7/libbeat/cmd/instance" - "github.com/elastic/beats/v7/metricbeat/beater" - "github.com/elastic/beats/v7/metricbeat/cmd/test" - "github.com/elastic/beats/v7/metricbeat/mb/module" -) - -// Name of this beat -var Name = "{beat}" - -// RootCmd to handle beats cli -var RootCmd *cmd.BeatsRootCmd - -var ( - // Use a customized instance of Metricbeat where startup delay has - // been disabled to workaround the fact that Modules() will return - // the static modules (not the dynamic ones) with a start delay. - testModulesCreator = beater.Creator( - beater.WithModuleOptions( - module.WithMetricSetInfo(), - module.WithMaxStartDelay(0), - ), - ) -) - -func init() { - RootCmd = cmd.GenRootCmdWithSettings(beater.DefaultCreator(), instance.Settings{Name: Name}) - RootCmd.AddCommand(cmd.GenModulesCmd(Name, "", BuildModulesManager)) - RootCmd.TestCmd.AddCommand(test.GenTestModulesCmd(Name, "", testModulesCreator)) -} diff --git a/generator/_templates/metricbeat/{beat}/include/include.go b/generator/_templates/metricbeat/{beat}/include/include.go deleted file mode 100644 index 8e731cdfc38..00000000000 --- a/generator/_templates/metricbeat/{beat}/include/include.go +++ /dev/null @@ -1 +0,0 @@ -package include diff --git a/generator/_templates/metricbeat/{beat}/magefile.go b/generator/_templates/metricbeat/{beat}/magefile.go deleted file mode 100644 index 701f4b2a478..00000000000 --- a/generator/_templates/metricbeat/{beat}/magefile.go +++ /dev/null @@ -1,137 +0,0 @@ -//go:build mage -// +build mage - -package main - -import ( - "fmt" - "time" - - "github.com/magefile/mage/mg" - - devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/dev-tools/mage/target/build" - "github.com/elastic/beats/v7/dev-tools/mage/target/collectors" - "github.com/elastic/beats/v7/dev-tools/mage/target/common" - "github.com/elastic/beats/v7/dev-tools/mage/target/pkg" - "github.com/elastic/beats/v7/dev-tools/mage/target/unittest" - metricbeat "github.com/elastic/beats/v7/metricbeat/scripts/mage" - - // mage:import - _ "github.com/elastic/beats/v7/metricbeat/scripts/mage/target/metricset" -) - -func init() { - devtools.SetBuildVariableSources(devtools.DefaultBeatBuildVariableSources) - - devtools.BeatDescription = "One sentence description of the Beat." - devtools.BeatVendor = "{full_name}" - devtools.CrossBuildMountModcache = true -} - -// CollectAll generates the docs and the fields. -func CollectAll() { - mg.Deps(collectors.CollectDocs, FieldsDocs) -} - -// Package packages the Beat for distribution. -// Use SNAPSHOT=true to build snapshots. -// Use PLATFORMS to control the target platforms. -func Package() { - start := time.Now() - defer func() { fmt.Println("package ran for", time.Since(start)) }() - - devtools.UseCommunityBeatPackaging() - devtools.PackageKibanaDashboardsFromBuildDir() - - mg.Deps(Update) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) - mg.SerialDeps(devtools.Package, pkg.PackageTest) -} - -// FieldsDocs generates docs/fields.asciidoc containing all fields -// (including x-pack). -func FieldsDocs() error { - inputs := []string{ - devtools.OSSBeatDir("module"), - } - output := devtools.CreateDir("build/fields/fields.all.yml") - if err := devtools.GenerateFieldsYAMLTo(output, inputs...); err != nil { - return err - } - return devtools.Docs.FieldDocs(output) -} - -// Fields generates a fields.yml for the Beat. -func Fields() error { - return devtools.GenerateFieldsYAML("module") -} - -// Config generates both the short/reference/docker configs. -func Config() { - mg.Deps(configYML, metricbeat.GenerateDirModulesD) -} - -func configYML() error { - p := devtools.DefaultConfigFileParams() - p.Templates = append(p.Templates, "_meta/config/*.tmpl") - return devtools.Config(devtools.AllConfigTypes, p, ".") -} - -// Clean cleans all generated files and build artifacts. -func Clean() error { - return devtools.Clean() -} - -// Check formats code, updates generated content, check for common errors, and -// checks for any modified files. -func Check() { - common.Check() -} - -// Fmt formats source code (.go and .py) and adds license headers. -func Fmt() { - common.Fmt() -} - -// Update is an alias for running fields, dashboards, config. -func Update() { - mg.SerialDeps(Fields, Dashboards, Config, Imports) -} - -// Dashboards collects all the dashboards and generates index patterns. -func Dashboards() error { - return devtools.KibanaDashboards("module") -} - -// Imports generates an include/list.go file containing -// a import statement for each module and dataset. -func Imports() error { - return devtools.GenerateModuleIncludeListGo() -} - -// Test runs all available tests -func Test() { - mg.Deps(unittest.GoUnitTest) -} - -// Build builds the Beat binary. -func Build() error { - return build.Build() -} - -// CrossBuild cross-builds the beat for all target platforms. -func CrossBuild() error { - return build.CrossBuild() -} - -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return build.BuildGoDaemon() -} - -// GolangCrossBuild build the Beat binary inside of the golang-builder. -// Do not use directly, use crossBuild instead. -func GolangCrossBuild() error { - return build.GolangCrossBuild() -} diff --git a/generator/_templates/metricbeat/{beat}/main.go b/generator/_templates/metricbeat/{beat}/main.go deleted file mode 100644 index 223a026ff88..00000000000 --- a/generator/_templates/metricbeat/{beat}/main.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "os" - - "{beat_path}/cmd" - - // Make sure all your modules and metricsets are linked in this file - _ "{beat_path}/include" -) - -func main() { - if err := cmd.RootCmd.Execute(); err != nil { - os.Exit(1) - } -} diff --git a/generator/_templates/metricbeat/{beat}/make.bat b/generator/_templates/metricbeat/{beat}/make.bat deleted file mode 100644 index 72de5798dfa..00000000000 --- a/generator/_templates/metricbeat/{beat}/make.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -REM Windows wrapper for Mage (https://magefile.org/) that installs it -REM to %GOPATH%\bin from the Beats vendor directory. -REM -REM After running this once you may invoke mage.exe directly. - -WHERE mage -IF %ERRORLEVEL% NEQ 0 go install {beat_path}/vendor/github.com/magefile/mage - -mage %* diff --git a/generator/_templates/metricbeat/{beat}/tools/tools.go b/generator/_templates/metricbeat/{beat}/tools/tools.go deleted file mode 100644 index 1ddaba8a29d..00000000000 --- a/generator/_templates/metricbeat/{beat}/tools/tools.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build tools -// +build tools - -// This package contains the tool dependencies of the project. - -package tools - -import ( - _ "github.com/blakesmith/ar" - _ "github.com/cavaliercoder/go-rpm" - _ "github.com/magefile/mage" - _ "github.com/mitchellh/gox" - _ "github.com/pierrre/gotestcover" - _ "github.com/tsg/go-daemon" - _ "golang.org/x/lint/golint" - _ "golang.org/x/tools/cmd/goimports" - _ "gotest.tools/gotestsum/cmd" -) diff --git a/generator/common/Makefile b/generator/common/Makefile deleted file mode 100644 index 8d82a444e84..00000000000 --- a/generator/common/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -PWD=$(shell pwd) -BEAT_TYPE?=beat -BEAT_NAME?=beatpath/test${BEAT_TYPE} -BEAT_PATH=${GOPATH}/src/${BEAT_NAME} -ES_BEATS=${GOPATH}/src/github.com/elastic/beats -PREPARE_COMMAND?= - --include ${ES_BEATS}/dev-tools/make/mage-install.mk - -# Runs test build for mock beat -.PHONY: test -test: prepare-test - cd ${BEAT_PATH} ; \ - export PATH=$${GOPATH}/bin:$${PATH}; \ - git config user.email "beats-jenkins@test.com" || exit 1 ; \ - git config user.name "beats-jenkins" || exit 1 ; \ - $(MAKE) check CHECK_HEADERS_DISABLED=y || exit 1 ; \ - $(MAKE) || exit 1 ; \ - mage test - -.PHONY: test-package -test-package: test - cd ${BEAT_PATH} ; \ - export PATH=$${GOPATH}/bin:$${PATH}; \ - mage package - -.PHONY: prepare-test -prepare-test:: mage - rm -fr ${BEAT_PATH} - mkdir -p ${BEAT_PATH} - cd ${GOPATH}/src/github.com/elastic/beats/ ; \ - export MODULE=elastic ; \ - export METRICSET=test ; \ - export NEWBEAT_PROJECT_NAME=Testbeat ; \ - export NEWBEAT_GITHUB_NAME=ruflin ; \ - export NEWBEAT_BEAT_PATH=${BEAT_NAME} ; \ - export NEWBEAT_FULL_NAME="Nicolas Ruflin" ; \ - export NEWBEAT_TYPE=${BEAT_TYPE} ; \ - export NEWBEAT_DEV=1 ; \ - export NEWBEAT_BEATS_REVISION=$(shell git rev-parse origin/master) ; \ - mage GenerateCustomBeat - -# Runs test build for the created beat -.PHONY: test-build -test-build: test - cd ${BEAT_PATH}/dev-tools/packer ; \ - $(MAKE) deps ; \ - $(MAKE) images - -# Cleans up environment -.PHONY: clean -clean: - rm -rf ${BEAT_PATH} diff --git a/generator/common/beatgen/beatgen.go b/generator/common/beatgen/beatgen.go deleted file mode 100644 index 48c83958278..00000000000 --- a/generator/common/beatgen/beatgen.go +++ /dev/null @@ -1,238 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package beatgen - -import ( - "bufio" - "fmt" - "go/build" - "os" - "path/filepath" - "strings" - - "github.com/magefile/mage/mg" - "github.com/magefile/mage/sh" - "github.com/pkg/errors" - - devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/dev-tools/mage/gotool" - "github.com/elastic/beats/v7/generator/common/beatgen/setup" -) - -// ConfigItem represents a value that must be configured for the custom beat -type ConfigItem struct { - Key string - Default func(map[string]string) string - Help string -} - -// required user config for a custom beat -// These are specified in env variables with newbeat_* -var configList = []ConfigItem{ - { - Key: "project_name", - Help: "Enter the beat name", - Default: func(cfg map[string]string) string { - return "examplebeat" - }, - }, - { - Key: "github_name", - Help: "Enter your github name", - Default: func(cfg map[string]string) string { - return "your-github-name" - }, - }, - { - Key: "beat_path", - Help: "Enter the beat path", - Default: func(cfg map[string]string) string { - ghName, _ := cfg["github_name"] - beatName, _ := cfg["project_name"] - return "github.com/" + ghName + "/" + strings.ToLower(beatName) - }, - }, - { - Key: "full_name", - Help: "Enter your full name", - Default: func(cfg map[string]string) string { - return "Firstname Lastname" - }, - }, - { - Key: "type", - Help: "Enter the beat type", - Default: func(cfg map[string]string) string { - return "beat" - }, - }, - { - Key: "beats_revision", - Help: "Enter the github.com/elastic/beats revision", - Default: func(cfg map[string]string) string { - return "master" - }, - }, -} - -// Generate generates a new custom beat -func Generate() error { - fmt.Println("Generating custom Beats are going to be removed in 8.0.0.") - - cfg, err := getConfig() - if err != nil { - return errors.Wrap(err, "error getting config") - } - beatsModuleName, err := gotool.GetModuleName() - if err != nil { - return err - } - - // Make sure the ElasticBeatsDir value is cached - // before changing directory below. - if _, err := devtools.ElasticBeatsDir(); err != nil { - return err - } - - err = setup.GenNewBeat(cfg) - if err != nil { - return errors.Wrap(err, "error generating new beat") - } - - absBeatPath := filepath.Join(build.Default.GOPATH, "src", cfg["beat_path"]) - - err = os.Chdir(absBeatPath) - if err != nil { - return errors.Wrap(err, "error changing directory") - } - - mg.Deps(setup.InitModule) - - err = getConfiguredBeatsRevision(beatsModuleName, cfg["beats_revision"]) - if err != nil { - return errors.Wrap(err, "error while getting required beats version") - } - - // After fully populating go.mod download the deps to set the hashes - // within the go.sum. - if err = gotool.Mod.Download(); err != nil { - return errors.Wrap(err, "failed to download go.mod deps") - } - // Finally, cleanup any formatting issues in the go.mod/go.sum. - if err = gotool.Mod.Tidy(); err != nil { - return errors.Wrap(err, "error running 'go mod tidy'") - } - - mg.Deps(setup.GitInit) - - if cfg["type"] == "metricbeat" { - //This is runV because it'll ask for user input, so we need stdout. - err = sh.RunV("make", "create-metricset") - if err != nil { - return errors.Wrap(err, "error running create-metricset") - } - } - - mg.Deps(setup.Update) - mg.Deps(setup.GitAdd) - - fmt.Printf("=======================\n") - fmt.Printf("Your custom beat is now available as %s\n", absBeatPath) - fmt.Printf("=======================\n") - - return nil -} - -func getConfiguredBeatsRevision(beatsModule, revision string) error { - beatsPkg := beatsModule + "@" + revision - return gotool.Get( - gotool.Get.Download(), - gotool.Get.Update(), - gotool.Get.Package(beatsPkg), - ) -} - -// VendorUpdate updates the vendor directory if used -func VendorUpdate() error { - err := sh.Rm("./vendor/github.com/elastic/beats") - if err != nil { - return errors.Wrap(err, "error removing vendor dir") - } - - devtools.SetElasticBeatsDir(getAbsoluteBeatsPath()) - return setup.CopyVendor() -} - -// returns a "compleated" config object with everything we need -func getConfig() (map[string]string, error) { - userCfg := make(map[string]string) - for _, cfgVal := range configList { - var cfgKey string - var err error - cfgKey, isSet := getEnvConfig(cfgVal.Key) - if !isSet { - cfgKey, err = getValFromUser(cfgVal.Help, cfgVal.Default(userCfg)) - if err != nil { - return userCfg, err - } - } - userCfg[cfgVal.Key] = cfgKey - } - - return userCfg, nil - -} - -func getEnvConfig(cfgKey string) (string, bool) { - EnvKey := fmt.Sprintf("%s_%s", setup.CfgPrefix, strings.ToUpper(cfgKey)) - - envKey := os.Getenv(EnvKey) - - if envKey == "" { - return envKey, false - } - return envKey, true -} - -// getValFromUser returns a config object from the user. If they don't enter one, fallback to the default -func getValFromUser(help, def string) (string, error) { - reader := bufio.NewReader(os.Stdin) - - // Human-readable prompt - fmt.Printf("%s [%s]: ", help, def) - str, err := reader.ReadString('\n') - if err != nil { - return "", err - } - if str == "\n" { - return def, nil - } - return strings.TrimSpace(str), nil - -} - -// getAbsoluteBeatsPath tries to infer the "real" non-vendor beats path -func getAbsoluteBeatsPath() string { - beatsImportPath := "github.com/elastic/beats" - gopath := os.Getenv("GOPATH") - if gopath != "" { - return filepath.Join(gopath, "src", beatsImportPath) - } - return filepath.Join(build.Default.GOPATH, "src", beatsImportPath) - -} diff --git a/generator/common/beatgen/setup/creator.go b/generator/common/beatgen/setup/creator.go deleted file mode 100644 index d6e07d2228f..00000000000 --- a/generator/common/beatgen/setup/creator.go +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package setup - -import ( - "fmt" - "go/build" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/pkg/errors" - - devtools "github.com/elastic/beats/v7/dev-tools/mage" -) - -// CfgPrefix specifies the env variable prefix used to configure the beat -const CfgPrefix = "NEWBEAT" - -// GenNewBeat generates a new custom beat -// We assume our config object is populated and valid here -func GenNewBeat(config map[string]string) error { - if config["type"] != "beat" && config["type"] != "metricbeat" { - return fmt.Errorf("%s is not a valid custom beat type. Valid types are 'beat' and 'metricbeat'", config["type"]) - } - - genPath := devtools.OSSBeatDir("generator", "_templates", config["type"], "{beat}") - err := filepath.Walk(genPath, func(path string, info os.FileInfo, err error) error { - newBase := filepath.Join(build.Default.GOPATH, "src", config["beat_path"]) - replacePath := strings.Replace(path, genPath, newBase, -1) - - writePath := strings.Replace(replacePath, "{beat}", config["project_name"], -1) - writePath = strings.Replace(writePath, ".go.tmpl", ".go", -1) - if info.IsDir() { - err := os.MkdirAll(writePath, 0755) - if err != nil { - return errors.Wrapf(err, "error creating directory %s", writePath) - } - } else { - - //dump original source file - tmplFile, err := ioutil.ReadFile(path) - if err != nil { - return errors.Wrap(err, "error reading source templatse file") - } - newFile := replaceVars(config, string(tmplFile)) - - err = ioutil.WriteFile(writePath, []byte(newFile), 0644) - if err != nil { - return errors.Wrap(err, "error writing beat file") - } - } - - return nil - }) - - return err -} - -// replaceVars replaces any template vars in a target file -// We're not using the golang template engine as it seems a tad heavy-handed for this use case -// We have a dozen or so files across various languages (go, make, etc) and most just need one or two vars replaced. -func replaceVars(config map[string]string, fileBody string) string { - var newBody = fileBody - config["beat"] = strings.ToLower(config["project_name"]) - for tmplName, tmplValue := range config { - tmplStr := fmt.Sprintf("{%s}", tmplName) - newBody = strings.ReplaceAll(newBody, tmplStr, tmplValue) - } - - return newBody -} diff --git a/generator/common/beatgen/setup/setup.go b/generator/common/beatgen/setup/setup.go deleted file mode 100644 index d797fd4416c..00000000000 --- a/generator/common/beatgen/setup/setup.go +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package setup - -import ( - "bufio" - "os" - "path/filepath" - - "github.com/magefile/mage/sh" - "github.com/pkg/errors" - - devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/dev-tools/mage/gotool" -) - -func InitModule() error { - err := gotool.Mod.Init() - if err != nil { - return errors.Wrap(err, "error initializing a module for the Beat") - } - - err = copyReplacedModules() - if err != nil { - return errors.Wrap(err, "error adding replaced modules to go.mod") - } - return gotool.Mod.Tidy() -} - -func copyReplacedModules() error { - const goModPath = "go.mod" - - beatPath, err := devtools.ElasticBeatsDir() - if err != nil { - return errors.Wrap(err, "error determining path to github.com/elastic/beats") - } - - inMod, err := os.Open(filepath.Join(beatPath, goModPath)) - if err != nil { - return errors.Wrap(err, "error opening go.mod file of github.com/elastic/beats") - } - defer inMod.Close() - - s := bufio.NewScanner(inMod) - inReplaceSection := false - replacedLines := []string{ - "", - "replace (", - } - for s.Scan() { - if err := s.Err(); err != nil { - return errors.Wrap(err, "error reading go.mod file") - } - - line := s.Text() - if inReplaceSection { - replacedLines = append(replacedLines, line) - - if line == ")" { - break - } - continue - } - - if line == "replace (" { - inReplaceSection = true - } - } - - outMod, err := os.OpenFile(goModPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0640) - if err != nil { - return errors.Wrap(err, "error opening the go.mod file of the generated Beat") - } - defer outMod.Close() - - w := bufio.NewWriter(outMod) - for _, rep := range replacedLines { - _, err = w.WriteString(rep + "\n") - if err != nil { - return errors.Wrap(err, "error writing replace lines to go.mod file") - } - } - - return w.Flush() -} - -// CopyVendor copies a new version of the dependencies to the vendor folder -func CopyVendor() error { - err := gotool.Mod.Vendor() - if err != nil { - return errors.Wrapf(err, "error while running go mod vendor") - } - - err = devtools.CopyFilesToVendor( - "./vendor", - []devtools.CopyModule{ - devtools.CopyModule{ - Name: "github.com/elastic/beats/v7", - FilesToCopy: []string{ - "dev-tools", - "libbeat", - "licenses", - "metricbeat", - "script", - ".go-version", - }, - }, - devtools.CopyModule{ - Name: "github.com/tsg/go-daemon", - FilesToCopy: []string{ - "src", - }, - }, - }, - ) - if err != nil { - return errors.Wrapf(err, "error while copying required files to vendor") - } - - return nil -} - -// GitInit initializes a new git repo in the current directory -func GitInit() error { - return sh.Run("git", "init") -} - -// GitAdd adds the current working directory to git and does an initial commit -func GitAdd() error { - err := sh.Run("git", "add", "-A") - if err != nil { - return errors.Wrap(err, "error running git add") - } - return sh.Run("git", "commit", "-q", "-m", "Initial commit, Add generated files") -} - -// Update updates the generated files (aka make update). -func Update() error { - err := sh.Run("make", "update") - if err != nil { - return err - } - return gotool.Mod.Tidy() -} diff --git a/heartbeat/magefile.go b/heartbeat/magefile.go index 40cc655ab1f..6b911478b50 100644 --- a/heartbeat/magefile.go +++ b/heartbeat/magefile.go @@ -27,7 +27,6 @@ import ( "github.com/magefile/mage/mg" devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/generator/common/beatgen" heartbeat "github.com/elastic/beats/v7/heartbeat/scripts/mage" // mage:import @@ -48,11 +47,6 @@ func init() { integtest.RegisterPythonTestDeps(Fields) } -// VendorUpdate updates elastic/beats/v7 in the vendor dir -func VendorUpdate() error { - return beatgen.VendorUpdate() -} - // Package packages the Beat for distribution. // Use SNAPSHOT=true to build snapshots. // Use PLATFORMS to control the target platforms. diff --git a/magefile.go b/magefile.go index 70b9f6cfecf..f2189e227b6 100644 --- a/magefile.go +++ b/magefile.go @@ -29,8 +29,6 @@ import ( "github.com/pkg/errors" "go.uber.org/multierr" - "github.com/elastic/beats/v7/generator/common/beatgen" - devtools "github.com/elastic/beats/v7/dev-tools/mage" "github.com/elastic/beats/v7/dev-tools/mage/gotool" ) @@ -47,11 +45,6 @@ var ( } ) -// GenerateCustomBeat generates a new custom beat -func GenerateCustomBeat() error { - return beatgen.Generate() -} - // PackageBeatDashboards packages the dashboards from all Beats into a zip // file. The dashboards must be generated first. func PackageBeatDashboards() error { diff --git a/x-pack/heartbeat/magefile.go b/x-pack/heartbeat/magefile.go index 0427001f11a..a7cd2b442ee 100644 --- a/x-pack/heartbeat/magefile.go +++ b/x-pack/heartbeat/magefile.go @@ -15,7 +15,6 @@ import ( "github.com/magefile/mage/mg" devtools "github.com/elastic/beats/v7/dev-tools/mage" - "github.com/elastic/beats/v7/generator/common/beatgen" heartbeat "github.com/elastic/beats/v7/heartbeat/scripts/mage" // mage:import @@ -37,11 +36,6 @@ func init() { devtools.BeatLicense = "Elastic License" } -// VendorUpdate updates elastic/beats/v7 in the vendor dir -func VendorUpdate() error { - return beatgen.VendorUpdate() -} - // Package packages the Beat for distribution. // Use SNAPSHOT=true to build snapshots. // Use PLATFORMS to control the target platforms.