How to compile filebeat source code?

I've developed my own 'output' and I've introduced it to the publisher.
Now I have a problem that I want to compile it and use it in a production mode.
I've checked the 'developer' doc and I didn't find anything for it except make testsuite which setups too many Docker images.

So, how can I use Filebeat in production mode by compiling the source code completely?


You can compile Filebeat by running mage build in the root of the beat. It creates a Filebeat binary for you.

What do you mean by production mode?

Thank you.
Well I've changed some parts of the code and I want to build and run it on the server. By production I mean that all parts work well for production and not just for development.

I've tried mage build but it shows this error: Unknown target specified: build

it compiles libbeat file by this action:

cd elastic/beats/libbeat
mage -l
mage build

It only says:

  "@timestamp": "2019-03-27T16:43:50.725Z",
  "@metadata": {
    "beat": "mockbeat",
    "type": "doc",
    "version": "9.9.9"
  "host": {
    "name": "myhost"
  "message": "Mockbeat is alive!",
  "type": "mock",
  "beat": {
    "name": "myhost",
    "hostname": "myhost",
    "version": "9.9.9"

It seems to be mock. So it seems that I did something wrong because it's not the production binary file.

Also it never supports 'output' like console: console output doesn't support testing.

Sample yml config file:

- type: log
  enabled: true
    - test.log

  pretty: true

You need to run it in the root of the beat. In this case filebeat.

Do you want to package it yourself to install it on you server?

By this action I've compiled and run it successfully:

$ cd ~/.go/src/
$ mage build
$ ./filebeat -e

and works fine.

Yes exactly. Would you please guide me how can package it by myself?

You can run make snapshot which creates a snapshot of the current codebase under build/distributions. To control which platform to build for set PLATFORMS.

To build packages for linux/amd64 you need to run the following command:

PLATFORMS=linux/amd64 make snapshot

This creates a DEB, an RPM and a tar.gz release.

1 Like

Thank you so much.

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