# Unable to compile custom beat based on metricbeat

**URL:** <https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085>\
**Category:** Beats\
**Tags:** beats-development\
**Created:** [March 8, 2018, 2:05pm UTC](https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085 "2018-03-08T14:05:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcroonen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dcroonen/32/27450_2.png) [@dcroonen](https://discuss.elastic.co/u/dcroonen)\
**Post date:** [March 8, 2018, 2:05pm UTC](https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085/1 "2018-03-08T14:05:40Z")

</div>

Hi all

After upgrading the Beat library from 6.0 to 6.2 I'm unable to package my custom Beat based on Metricbeat. The error message is:

> Step 4/9 : RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y flex bison  
> ---\> Running in fb281bd71978  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze Release.gpg  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze-lts Release.gpg  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze Release  
> Ign [http://archive.debian.org](http://archive.debian.org) squeeze Release  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze-lts Release  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze/main amd64 Packages  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze/contrib amd64 Packages  
> Hit [http://archive.debian.org](http://archive.debian.org) squeeze-lts/main amd64 Packages  
> Reading package lists...  
> W: GPG error: [http://archive.debian.org](http://archive.debian.org) squeeze Release: The following signatures were invalid: KEYEXPIRED 1520281423 KEYEXPIRED 1501892461  
> Reading package lists...  
> Building dependency tree...  
> Reading state information...  
> Suggested packages:  
> bison-doc  
> The following NEW packages will be installed:  
> bison flex  
> 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.  
> Need to get 911 kB of archives.  
> After this operation, 2925 kB of additional disk space will be used.  
> WARNING: The following packages cannot be authenticated!  
> flex bison  
> E: There are problems and -y was used without --force-yes  
> The command '/bin/sh -c apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y flex bison' returned a non-zero code: 100  
> Makefile:48: recipe for target 'xgo-image' failed  
> make[1]: \*\*\* [xgo-image] Error 100  
> make[1]: Leaving directory '/opt/bamboo-agent-home/xml-data/build-dir/SMB-REL-JOB1/src/github.com/dcroonen/smartbeat/vendor/github.com/elastic/beats/dev-tools/packer'  
> vendor/github.com/elastic/beats/libbeat/scripts/Makefile:423: recipe for target 'package-setup' failed  
> make: \*\*\* [package-setup] Error 2

I understood from [this](https://discuss.elastic.co/t/xgo-deb6-base-docker-image-doesnt-build-on-linux-kernel-4-8-0/65805), it has something to do with C support for GO. As I don't use any C libraries in my GO code I don't need either the C support. Their is a variable, called CGO set to true in vendor/github.com/elastic/beats/libbeat/scripts/Makefile, of which I think that it should handle this but setting this variable to false doesn't do anything.

Anybody any thougths? Anybody knowing how to turn this off?

Kind regards  
Davy

---

<div class="post-metadata">

**Author:** ![dcroonen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dcroonen/32/27450_2.png) [@dcroonen](https://discuss.elastic.co/u/dcroonen)\
**Post date:** [March 9, 2018, 7:41am UTC](https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085/2 "2018-03-09T07:41:16Z")

</div>

Ok I mananged to get this through by commenting out line 50 and 51 in `vendor/github.com/elastic/beats/dev-tools/packer/Makefile` and by running the `make package` command with the options `SNAPSHOT=no CGO=false PACKAGES=${BEAT_NAME}/deb TARGETS="linux/amd64 linux/386"`.

Note: This only builds .deb packages but at the moment this is enough for my purposes.

Anybody any thoughts on this because commenting out lines in Makefiles doesn't feel as the right way to go?

Regards

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 12, 2018, 9:18am UTC](https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085/3 "2018-03-12T09:18:29Z")

</div>

I wonder if the above issue is related to some recent issues we had with debian 6.

About the variables: Instead of changing the Makefile you can overload them when calling the command like `CGO=false make package`.

---

<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 9, 2018, 9:18am UTC](https://discuss.elastic.co/t/unable-to-compile-custom-beat-based-on-metricbeat/123085/4 "2018-04-09T09:18:33Z")

</div>

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