# Build filebeat x-pack modules from source fails

**URL:** <https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [April 1, 2020, 9:33pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128 "2020-04-01T21:33:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 1, 2020, 9:33pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/1 "2020-04-01T21:33:02Z")

</div>

I have managed to build file beat and base modules from source found at [https://github.com/elastic/beats](https://github.com/elastic/beats) . When I try to build the modules in beats/x-pack/filebeat I receive the following error with build launched at src/github.com/elastic/beats/x-pack/filebeat

```auto
mage build
>> build: Building filebeat
../libbeat/cmd/inject.go:17:2: build constraints exclude all Go files in /root/go/src/github.com/elastic/beats/x-pack/libbeat/processors/add_cloudfoundry_metadata
Error: running "go build -o filebeat -ldflags -s -X github.com/elastic/beats/v7/libbeat/version.buildTime=2020-04-01T21:26:46Z -X github.com/elastic/beats/v7/libbeat/version.commit=0ef472268ea41881f81accabe2af6cfb72eef682" failed with exit code 1

```

I have little experience with Go and so am lost as far as troubleshooting this goes. The one things that I notice is the reference to the [github.com/elastic/beats/v7](http://github.com/elastic/beats/v7) which does not exists in the source tree.

```auto
go version go1.14.1 freebsd/amd64

go env : 
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/root/go/src/github.com/elastic/beats/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build279549248=/tmp/go-build -gno-record-gcc-switches"

```

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [April 2, 2020, 8:40am UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/2 "2020-04-02T08:40:49Z")

</div>

Hi @Mike_Ware!

I was not able to reproduce this one:

```auto
~/go/src/github.com/elastic/beats/x-pack/filebeat git log --pretty=oneline                                                                              

495595d6240881661e9b15059f3fa70a5c400edc (HEAD -> master, upstream/master, origin/master) Remove dataType field of query metricset (#17383)
9009938d64c3f2c688b2b8ecd6afbb7108d0ddc3 Add pattern to handle logs from newer ES versions (#17406)
e3c72b308f6d4e3290690365aa7adb6939608dec [Filebeat] Improve ECS categorization field mappings for mssql module (#17376)
e7229a4d36de8bb55e5c41958374e064b9ea38fe [Filebeat] Improve ECS categorization field mappings for mongodb module (#17371)

```

And:

```auto
~/go/src/github.com/elastic/beats/x-pack/filebeat mage build                                                                                            
>> build: Building filebeat
 ~/go/src/github.com/elastic/beats/x-pack/filebeat ./filebeat version                                                                                               
filebeat version 8.0.0 (amd64), libbeat 8.0.0 [495595d6240881661e9b15059f3fa70a5c400edc built 2020-04-02 08:39:10 +0000 UTC]

```

What could be different in your case?

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 2, 2020, 4:54pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/3 "2020-04-02T16:54:31Z")

</div>

Hi Chris thanks for your reply. I am on freebsd 11.3 which could be a difference. Is there a solid set of instructions for setting up the build environment? I feel like I may just be missing something simple that's killing me.

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 2, 2020, 11:57pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/4 "2020-04-02T23:57:02Z")

</div>

I just tried on a pretty fresh freebsd 12 system and it failed as well. Here's the entire process I followed.

Install python 3.8

Link python

ln -s /usr/local/bin/python3.8 /usr/local/bin/python

ln -s /usr/local/bin/python3.8 /usr/local/bin/python3

Install latest go  
wget [https://dl.google.com/go/go1.14.1.freebsd-386.tar.gz](https://dl.google.com/go/go1.14.1.freebsd-386.tar.gz)

tar -C /usr/local -xzf go1.14.1.freebsd-386.tar.gz

Add paths to profiles for execution

Install mage

go get -u -d [GitHub - magefile/mage: a Make/rake-like dev tool using Go](http://github.com/magefile/mage) cd $GOPATH/src/github.com/magefile/mage go run bootstrap.go

Clone beats repo  
Create /root/go/src/github.com/elastic folder and clone beats

git clone [GitHub - elastic/beats: 🐠 Beats - Lightweight shippers for Elasticsearch & Logstash](https://github.com/elastic/beats.git)

Build filebeat

~/go/src/github.com/elastic/beats/filebeat # mage build  
Succeeds

This is where we fail

~/go/src/github.com/elastic/beats/x-pack/filebeat # mage build

> > build: Building filebeat  
> > ../libbeat/cmd/inject.go:17:2: build constraints exclude all Go files in /root/go/src/github.com/elastic/beats/x-pack/libbeat/processors/add\_cloudfoundry\_metadata  
> > Error: running "go build -o filebeat -ldflags -s -X [github.com/elastic/beats/v7/libbeat/version.buildTime=2020-04-02T16:42:12Z](http://github.com/elastic/beats/v7/libbeat/version.buildTime=2020-04-02T16:42:12Z) -X [github.com/elastic/beats/v7/libbeat/version.commit=ee1d6f57dffc73d579a22e0ea330cc6ec3bf34ce](http://github.com/elastic/beats/v7/libbeat/version.commit=ee1d6f57dffc73d579a22e0ea330cc6ec3bf34ce)" failed with exit code 1

---

<div class="post-metadata">

**Author:** ![blaker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blaker/32/65621_2.png) [@blaker](https://discuss.elastic.co/u/blaker)\
**Post date:** [April 3, 2020, 1:07pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/5 "2020-04-03T13:07:16Z")

</div>

@Mike_Ware Could you try to remove both of these lines to see if it will build?

> <https://github.com/elastic/beats/blob/aa13b468b71ec713b3f0aebaf813b57caf90a706/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata.go#L5>

> <https://github.com/elastic/beats/blob/aa13b468b71ec713b3f0aebaf813b57caf90a706/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata_test.go#L5>

I think those lines might have been added when they are really not required for cloudfoundry.

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 3, 2020, 4:02pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/6 "2020-04-03T16:02:36Z")

</div>

@blaker Thanks for the tip, but neither of those files exist in my source tree. In fact there is no blob folder at all. find /root/go/src/ -name blob returns nothing and the metadata files are not in the path you proposed. Did I miss a step in generating?

I did find it in the libbeat x-pack tree.

find /root/go/src/ -name add\_cloudfoundry\_metadata.go

/root/go/src/github.com/elastic/beats/x-pack/libbeat/processors/add\_cloudfoundry\_metadata/add\_cloudfoundry\_metadata.go

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 3, 2020, 4:42pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/7 "2020-04-03T16:42:44Z")

</div>

Also interesting is it looks as though the automated build is failing : [https://travis-ci.org/github/elastic/beats/jobs/670282371](https://travis-ci.org/github/elastic/beats/jobs/670282371)

---

<div class="post-metadata">

**Author:** ![blaker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blaker/32/65621_2.png) [@blaker](https://discuss.elastic.co/u/blaker)\
**Post date:** [April 3, 2020, 5:29pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/8 "2020-04-03T17:29:49Z")

</div>

@Mike_Ware The job you linked to shows passed.

Yes you need to update it in that path that you found with `find`. Where you able to get it to build with that line removed?

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 3, 2020, 5:52pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/9 "2020-04-03T17:52:57Z")

</div>

@blaker Ah strange it was showing as failing when I posted. And yes removing that line has fixed the build. Thanks so much for your help I thought I was going crazy or just missing something very simple!

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 3, 2020, 6:14pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/10 "2020-04-03T18:14:48Z")

</div>

@blaker one last question, Is there a way to cleanly install from source? I've tried make/mage/gmake install with no luck.

---

<div class="post-metadata">

**Author:** ![blaker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blaker/32/65621_2.png) [@blaker](https://discuss.elastic.co/u/blaker)\
**Post date:** [April 3, 2020, 6:40pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/11 "2020-04-03T18:40:17Z")

</div>

@Mike_Ware `mage build` in the directory should produce an output in `build/`. From there you can just use the binary, can move it to `/usr/local/bin` if you would like.

I have a fix going in to remove those lines so you do not need the modifications.

> <https://github.com/elastic/beats/pull/17486>

---

<div class="post-metadata">

**Author:** ![Mike\_Ware](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_ware/32/46467_2.png) [@Mike\_Ware](https://discuss.elastic.co/u/Mike_Ware)\
**Post date:** [April 3, 2020, 7:58pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/12 "2020-04-03T19:58:00Z")

</div>

@blaker thanks much appreciated. I figured just moving was the easy way just wondering if I was missing something else in the build.

---

<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:** [May 1, 2020, 7:58pm UTC](https://discuss.elastic.co/t/build-filebeat-x-pack-modules-from-source-fails/226128/13 "2020-05-01T19:58:12Z")

</div>

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