In this post I’ll show you how to build and run Beats on Raspberry Pi.
Firstly, you’ll need to install go. Beats requires Go version 1.5.3 or higher (at the time of writing.) Unfortunately this process is a little roundabout as you must first install go 1.4.x in order to install 1.5.x. Convenient! </sarcasm>
If you’ve already followed my tutorial for building Logstash Forward on a Raspberry Pi you can skip the step for installing go 1.4. Otherwise grab the latest sources from the Go Downloads. I’ll be using 1.4.2 below, but you should update the wget link with the link of the version you plan on using. The below script will remove any existing go install, so be careful if you want another go version for other things.
which go && sudo rm -rf /usr/bin/go* /usr/local/go cd ~ wget https://storage.googleapis.com/golang/go1.4.2.src.tar.gz sudo tar -C /usr/local -xvf go1.4.*.tar.gz cd /usr/local/go/src sudo ./make.bash
That will take a while to build. Once it’s complete download and install Go 1.5.x (grabbing the latest version, as before):
cd ~ wget https://storage.googleapis.com/golang/go1.5.3.src.tar.gz sudo tar -xvf go1.5.*.tar.gz sudo mv go /usr/local/go1.5 cd /usr/local/go1.5/src sudo GOROOT_BOOTSTRAP=/usr/local/go ./make.bash sudo ln -s /usr/local/go1.5/bin/* /usr/bin
Once you have go 1.5.x installed, you’re ready to get on the way to installing beats. First however, you’ll need to install a bunch of dependencies:
mkdir -p /usr/local/go1.5/src/github.com/elastic sudo chown -R pi /usr/local/go1.5/src/github.com #change to your username if not "pi" cd /usr/local/go1.5/src/github.com/elastic git clone https://github.com/elastic/beats export GOROOT=/usr/local/go1.5/
Next install of the go dependencies for the project:
export GOPATH=/usr/local/go1.5/src/github.com/elastic/beats # Install easy go deps go get golang.org/x/text/encoding/charmap go get golang.org/x/text/encoding/simplifiedchinese go get golang.org/x/text/encoding/unicode go get golang.org/x/text/transform go get gopkg.in/yaml.v2 go get github.com/garyburd/redigo/redis go get github.com/nranchev/go-libGeoIP go get github.com/satori/go.uuid
Now that we have all of the dependencies its time to actually go about compiling Beats. To do so, compile the individual beats you need. The process looks like this:
cd /usr/local/go1.5/src/github.com/elastic/beats # Pick a beat to compile. Choose from "filebeat", "topbeat", or "packetbeat" cd filebeat make sudo cp filebeat /usr/bin/ # can also use "sudo ln -s filebeat /usr/bin" if you plan on keeping the sources around
There you go! Compile each beat that you want to use and enjoy!