How to build beats in windows

i'm currently trying to build a beats plugin to get some windows specific info so trying to build it on windows

seams there is lot of dependency on Linux to develop the beats

if i try to do make setup it says mkdir cmd not found which is linux cmd

question is how to build any beats which pulls windows specific metrics like metric-beat

Thanks
Manju

Are you running a fresh copy of master? We recently did a lot of change in the build system.

yes im using master

in new version can i build a beat in windows ??

@Manjukb mkdir should work with and without powershell, I just tested it on a windows 2012 vm.
Running make setup is usually verbose can you add the output of this command to this post?

What steps are your running to make your beats? I will try to reproduce the error.

@pierhugues i fallowed below steps

cloned elastic beats under src\github\elastic\beats
and created a folder under src\github with my github username

now i tried to generate sample beat using this cmd python ``Traceback (most recent call last): File ``"C:\Users\ManjunathKB\go\src\github.com\elastic\beats\script\generate.py"
project_name = raw_input("Beat Name [Examplebeat]: ") or ``"examplebeat"
NameError: name 'raw_input' is not defined

So i generated a sample beat in linux pushed it to git and cloned under Manjukb folder

now i tried to do make setup

C:\Users\ManjunathKB\go\src\github.com\Manjukb\smartcenterBeat>make setup

FIND: Parameter format not correct
FIND: Parameter format not correct
FIND: Parameter format not correct
mkdir -p vendor/github.com/elastic/
The syntax of the command is incorrect.
make: *** [copy-vendor] Error 1

make update

C:\Users\ManjunathKB\go\src\github.com\Manjukb\smartcenterBeat>make update
FIND: Parameter format not correct
FIND: Parameter format not correct
FIND: Parameter format not correct
process_begin: CreateProcess(NULL, pwd, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
'test' is not recognized as an internal or external command,
operable program or batch file.
'virtualenv' is not recognized as an internal or external command,
operable program or batch file.
make: *** [python-env] Error 1

please let me know if need more info

Thanks

Manju

Another solution will be to compile in Golang with GOOS = windosws ...

do you mean do this in linux ??

i just want to know how metric beat is developed

i think metric beat must be developed in windows env as it pulls windows specific data let me know if i'm wrong

please share how its built

Thanks

why it was withdrawn ??

1 Like

the compilation in linux, yes, but the binary, you can use it after in windows. using Golang . voila

the advantage with Golang is that you can compile, for example, your program and run it in an environment OS you want.

  1. https://github.com/elastic/beats
  2. https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
  3. https://stackoverflow.com/questions/20829155/how-to-cross-compile-from-windows-to-linux

ok if i compile it on Linux how i will get windows specific data

i have mentioned that i'm trying to pull windows specific data like
os version, process info and many more

please help

A metricbeat compiler for example, you will have both the executable and a configuration file yml to which you specify what you want to collect as data.

As someone who has developed lots of Go code that targets Windows I can share my process.

I run all of the make commands from a *nix machine. This is for all of the things that are not actually Go, like generating the configuration files and other ancillary files. This is because the make targets are not all that portable in Beats. We're slowly addressing this by migrating build logic out of make an into Go so that it is much more portable and will run on Windows.

My daily development environment is not Windows. When it comes to developing Go code for Windows, I still write the actually code on my *nix machine where I have my development environment. But I do my testing on Windows. So for code that does not require native compilers (your not using cgo) you can cross-compile a Windows binary by setting environment variables when building GOOS=windows GOARCH=amd64 go build then copy that .exe to Windows. But more frequently I will run a Windows VM and mount my GOPATH inside the VM so that I can simply run go build and go test from Windows.

1 Like

Thanks @andrewkroh, also I want to point out that we provide a Vagrantfile which I believe could help you getting started on *nix machine.

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