make elastic beat
Beatの構造
環境
- go 1.13.11
- python 3.6.9
手順
- 環境をつくる
sudo apt remove 'golang-*'
wget https://dl.google.com/go/go1.13.11.linux-amd64.tar.gz
tar xf go1.13.11.linux-amd64.tar.gz
sudo mv go /usr/local/go
mkdir -p $HOME/go
export GOPATH=$HOME/go >> ~/.bashrc
export GOROOT=/usr/local/go >> ~/.bashrc
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH >> ~/.bashrc
sudo apt install -y python3-dev python3-pip
pip3 install virtualenv
export PYTHON_EXE='python3'
export VIRTUALENV_PARAMS='-p python3'
export VIRTUALENV_PYTHON='/usr/bin/python3'
- mageをインストール
go get -u -d github.com/magefile/mage
cd $GOPATH/src/github.com/magefile/mage
go run bootstrap.go
// mageのバイナリが、$HOME/go/bin配下にある
- mageを使ってbeatのテンプレートを作成
bash
mkdir -p ${GOPATH}/src/github.com/{user}
mkdir -p ${GOPATH}/src/github.com/elastic
git clone https://github.com/elastic/beats ${GOPATH}/src/github.com/elastic/beats
cd $GOPATH/src/github.com/elastic/beats/
mage GenerateCustomBeat
Enter the beat name [examplebeat]: Countbeat
Enter your github name [your-github-name]: ak1ra24
Enter the beat path [github.com/ak1ra24/countbeat]:
Enter your full name [Firstname Lastname]: Taro Hoge
Enter the beat type [beat]:
- makeでバイナリ生成
cd ${GOPATH}/src/github.com/{user}
make
- コードを編集
config/config.go // configファイルで読み込む構造体を設定
beater/xxxbeat.go // 送信するイベントの値を設定および送信を書く
refs: