Skip to content

Instantly share code, notes, and snippets.

@lvaylet
Forked from anis-campos/cross-compile_filebeat_arm.sh
Last active September 13, 2021 08:01
Show Gist options
  • Save lvaylet/68b98f9723196ac324d93ff65f86580b to your computer and use it in GitHub Desktop.
Save lvaylet/68b98f9723196ac324d93ff65f86580b to your computer and use it in GitHub Desktop.
Cross-compile Elastic Filebeat for ARM with docker. Works on Raspberry Pi 2 and 3.

Elastic does not provide Filebeat binaries for ARMv7. Luckily, Filebeat can easily be cross-compiled with:

# ----- Instantiate an immutable Go container for cross-compilation ----- #
mkdir build && cd $_
docker run -it --rm -v `pwd`:/build golang:1.9 /bin/bash

# ----- Inside Go container ----- #
go get github.com/elastic/beats
cd /go/src/github.com/elastic/beats/filebeat/
git checkout v6.2.2
GOARCH=arm go build
cp filebeat /build
exit

# ----- Verify the output file ----- #
file filebeat
#filebeat: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

The newly built Filebeat binary can then be uploaded to the remote PCM3, for example with http://transfer.sh

On the PCM3:

@lvaylet
Copy link
Author

lvaylet commented Mar 6, 2018

Upgrade Go to 1.9 and Filebeat to 6.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment