Creating a Beat based on Metricbeat

edit

Creating a Beat based on Metricbeat

edit

The metricset Beat generator enables you to create a Beat that uses Metricbeat as a library and has your own metricsets.

Requirements

edit

To create your own Beat, you must have Golang 1.8.3 or later installed, and the $GOPATH must be set up correctly. In addition, the following tools are required:

Virtualenv is easiest installed with your package manager or pip.

Step 1 - Get the metricbeat source code

edit

The first step is to get the metricbeat source code:

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 (6.0 in the example below):

cd ${GOPATH}/src/github.com/elastic/beats
git checkout 6.0

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.

Step 2 - Create the Beat

edit

Run the command:

python ${GOPATH}/src/github.com/elastic/beats/script/generate.py --type=metricbeat

When prompted, enter the Beat name and path.

Step 3 - Init and create the metricset

edit

After creating the Beat, change the directory to $GOPATH/src/github.com/{your-github-name}/{beat} and run:

make setup

This will do the initial setup for your Beat and also run make create-metricset, which will ask you for the module name and metricset name of your Beat.

For more details about creating a metricset, see the docs Creating a Metricset.

Step 4 - Build & Run

edit

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.

./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.

Step 5 - Package

edit

To create packages and binaries for different plaforms, docker is required. The first step is to get the most recent packaging tools into your beat:

make package

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 Creating a Metricset.