# Self developed metricbeat module throws in docker a strange error

**URL:** <https://discuss.elastic.co/t/self-developed-metricbeat-module-throws-in-docker-a-strange-error/301560>\
**Category:** Beats\
**Tags:** docker, metricbeat\
**Created:** [April 4, 2022, 8:59pm UTC](https://discuss.elastic.co/t/self-developed-metricbeat-module-throws-in-docker-a-strange-error/301560 "2022-04-04T20:59:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PascalThalmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pascalthalmann/32/101672_2.png) [@PascalThalmann](https://discuss.elastic.co/u/PascalThalmann)\
**Post date:** [April 4, 2022, 8:59pm UTC](https://discuss.elastic.co/t/self-developed-metricbeat-module-throws-in-docker-a-strange-error/301560/1 "2022-04-04T20:59:36Z")

</div>

Hi,  
I developed a metricbeat module and metricset. I ran "mage update" and "mage build" and tested it in my VM and it ran perfectly.  
I then zipped the following files, copied dit to another VM (Ubuntu as well) and started it and it ran perfectly:

```auto
tar zcvf my_module.tar.gz module/my_module \
   fields.yml metricbeat.reference.yml \
   metricbeat.yml modules.d/my_module.yml metricbeat

```

Btw. my module has the name "My\_module" and my metricset has the name file\_mon.

Ok, then I wanted to containerize it, to deploy it with the following dockerfile:

```auto
FROM ubuntu:18.04 

RUN mkdir -p /metricbeat/modules.d
RUN apt update
RUN apt -y upgrade

COPY metricbeat /metricbeat
COPY metricbeat.yml /metricbeat
COPY metricbeat.reference.yml /metricbeat
COPY fields.yml /metricbeat
COPY modules.d/my_module.yml /metricbeat/modules.d/my_module.yml
EXPOSE 9200

CMD cd /metricbeat && ./metricbeat -e -d "*"

```

Now this is the strange part:

I always get this error message:

```auto
{"log.level":"error","@timestamp":"2022-04-04T20:44:10.000Z","log.origin":{"file.name":"runtime/panic.go","file.line":221},"message":"recovered from panic while fetching 'my_module/file_mon' for host 'localhost'. Recovering, but please report this.","service.name":"metricbeat","error":{"message":"runtime error: invalid memory address or nil pointer dereference"},"stack":"github.com/elastic/beats/v7/libbeat/logp.Recover\n\tgithub.com/elastic/beats/v7/libbeat/logp/global.go:102\nruntime.gopanic\n\truntime/panic.go:1038\nruntime.panicmem\n\truntime/panic.go:221\nruntime.sigpanic\n\truntime/signal_unix.go:735\ngithub.com/elastic/beats/v7/metricbeat/module/my_module/file_mon.(*MetricSet).Fetch\n\tgithub.com/elastic/beats/v7/metricbeat/module/my_module/file_mon/file_mon.go:72\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).fetch\n\tgithub.com/elastic/beats/v7/metricbeat/mb/module/wrapper.go:251\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).startPeriodicFetching\n\tgithub.com/elastic/beats/v7/metricbeat/mb/module/wrapper.go:223\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).run\n\tgithub.com/elastic/beats/v7/metricbeat/mb/module/wrapper.go:207\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*Wrapper).Start.func1\n\tgithub.com/elastic/beats/v7/metricbeat/mb/module/wrapper.go:147","ecs.version":"1.6.0"}

```

The crazy part is this: when I copy the system.yml module configfile and enable it and when i disable "my\_module", the error does not appear.

Has anyone experience with self written metricbeat modules and discovered the same error? Again, i can deploy the zip file to any machine and it runs smoothly. Even if i use another docker base image like centos:7 or [docker.elastic.co/beats/metricbeat:8.1.2](http://docker.elastic.co/beats/metricbeat:8.1.2) i am running into the same problem. the current version of metricbeat for the development environment is

```auto
./metricbeat version
metricbeat version 8.3.0 (amd64), libbeat 8.3.0 [7e22a97892a86d42a2d8966e70b942d564a32d69 built 2022-04-04 18:46:01 +0000 UTC]

```

Help is very appreciated

Thanks  
Pascal

---

<div class="post-metadata">

**Author:** ![PascalThalmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pascalthalmann/32/101672_2.png) [@PascalThalmann](https://discuss.elastic.co/u/PascalThalmann)\
**Post date:** [April 10, 2022, 4:45am UTC](https://discuss.elastic.co/t/self-developed-metricbeat-module-throws-in-docker-a-strange-error/301560/2 "2022-04-10T04:45:38Z")

</div>

I close the topic, since the problem has been solved.  
The panic was caused by a call on Go object, that was nil.  
To be more precise, i tried to read statistics of a file that was not existing.

See my journey [here](https://cdax.ch/2022/04/09/elasticsearch-beats-workshop-3-a-more-sophisticated-configuration-for-your-metricset/).

---

<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 8, 2022, 6:46am UTC](https://discuss.elastic.co/t/self-developed-metricbeat-module-throws-in-docker-a-strange-error/301560/3 "2022-05-08T06:46:26Z")

</div>

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