# New To Beats : Unable to build custom beat for cross-environment

**URL:** https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765
**Category:** Beats
**Created:** [March 15, 2017, 8:54pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765 "2017-03-15T20:54:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![deepujain](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@deepujain](https://discuss.elastic.co/u/deepujain)
#### Post date: [March 15, 2017, 8:54pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/1 "2017-03-15T20:54:48Z")

</div>

I was able to create a sample beat using developer guide (kudos to it). However when i make a beat in Mac am unable to run it on a linux x86 box. I provided "GOOS=linux GOARCH=386" in Makefile and then ran make. However the executable is not working in linux environment.

I see cannot execute binary file: Exec format error error when i run beat.

My machine is  
uname -a  
Linux 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86\_64 x86\_64 x86\_64 GNU/Linux

And i tried following options  
GOOS=linux  
GOARCH=amd64  
GOX\_FLAGS=-arch="amd64"  
#GOPACKAGES=$(shell glide novendor)

Appreciate your time.

---

<div class="post-metadata">

### Author: ![giuseppe](https://avatars.discourse-cdn.com/v4/letter/g/48db29/32.png) [@giuseppe](https://discuss.elastic.co/u/giuseppe)
#### Post date: [March 15, 2017, 9:45pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/2 "2017-03-15T21:45:02Z")

</div>

Hi Deepak,

I ran a similar test with a community beat I wrote and it worked:

```
openconfigbeat $ GOOS=linux GOARCH=amd64 make
go build
openconfigbeat $ docker run -ti -v `pwd`:/openconfigbeat ubuntu /openconfigbeat/openconfigbeat
openconfigbeat2017/03/15 21:46:17.114039 beat.go:369: CRIT Exiting: error loading config file: stat openconfigbeat.yml: no such file or directory
Exiting: error loading config file: stat openconfigbeat.yml: no such file or directory

```

For your reference the Makefile in this case looks like this:

> <https://github.com/aristanetworks/openconfigbeat/blob/master/Makefile>

---

<div class="post-metadata">

### Author: ![deepujain](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@deepujain](https://discuss.elastic.co/u/deepujain)
#### Post date: [March 15, 2017, 10:31pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/3 "2017-03-15T22:31:41Z")

</div>

> [@deepujain](#):
>
> linux

Hello Valente,  
Thanks for your time. I do not see GOOS and GOARCH options in makefile. When i put GOOS=linux  
GOARCH=amd64 in makefile and run make, the executable was not built for linux but for Mac (my local machine).

How do change Makefile so that the executable built is for linux amd64 ?  
Also, do i need to copy the configuration files (\*.yml) by myself to destination machine ?  
Generic question would be how is a beat packaged ?

Regards,  
Deepak

---

<div class="post-metadata">

### Author: ![giuseppe](https://avatars.discourse-cdn.com/v4/letter/g/48db29/32.png) [@giuseppe](https://discuss.elastic.co/u/giuseppe)
#### Post date: [March 15, 2017, 10:57pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/4 "2017-03-15T22:57:23Z")

</div>

`GOOS` and `GOARCH` are not there because if you pass them to your `make` command they just propagate to `go build` via `libbeat/scripts/Makefile` (see the related `include` statement in my Makefile). You do need to copy the `.yml` files in addition to your beat's binary.

---

<div class="post-metadata">

### Author: ![deepujain](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@deepujain](https://discuss.elastic.co/u/deepujain)
#### Post date: [March 15, 2017, 11:03pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/5 "2017-03-15T23:03:08Z")

</div>

My assumption was all settings goes into Makefile. I was incorrect.

Thanks.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 5, 2017, 8:55pm UTC](https://discuss.elastic.co/t/new-to-beats-unable-to-build-custom-beat-for-cross-environment/78765/6 "2017-04-05T20:55:03Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
