# Filebeat's docker metadata watcher losing container from its list somehow

**URL:** https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897
**Category:** Beats
**Tags:** filebeat
**Created:** [December 1, 2017, 9:00am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897 "2017-12-01T09:00:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![benben](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benben/32/6660_2.png) [@benben](https://discuss.elastic.co/u/benben)
#### Post date: [December 1, 2017, 9:00am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/1 "2017-12-01T09:00:16Z")

</div>

After some random time, the watcher looses some(?) active containers. In the log you can see that filebeat is still reading correctly from docker logs but then says, it cannot find the container with `add_docker_metadata.go:124: DBG Container not found:` (last line of the log).  
Also when I check in docker the container is still there and running but logs are not written to ES. Also the registry is updated. I need to restart the filebeat container and it will pickup the current time, which means I have gaps in my logs in ES.

I am running filebeats 6.0.0 in the official beats docker container.

```auto
tail_files: true
filebeat.prospectors:
  - type: log
    close_inactive: 24h
    paths:
      - '/var/lib/docker/containers/*/*.log'
    json.message_key: log
    json.keys_under_root: true
    processors:
    - add_docker_metadata: ~
    - decode_json_fields:
        fields: ["log"]
        target: ""
        when:
          equals:
            docker.container.name: nginx
output.elasticsearch:
  hosts: ["elasticsearch:9200"]

```

```auto
2017/12/01 08:47:53.115968 log.go:85: DBG End of file reached: /var/lib/docker/containers/41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325/41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.129626 client.go:282: DBG PublishEvents: 1 events have been published to elasticsearch in 13.731209ms.
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.129800 logger.go:29: DBG ackloop: receive ack [6176: 0, 1]
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.129871 logger.go:29: DBG broker ACK events: count=1, start-seq=33097, end-seq=33097
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.129978 logger.go:18: DBG ackloop: return ack to broker loop:1
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.130035 logger.go:18: DBG ackloop: done send ack
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.130134 registrar.go:200: DBG Processing 1 events
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.130258 registrar.go:195: DBG Registrar states cleaned up. Before: 15, After: 15
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.130293 registrar.go:228: DBG Write registry file: /usr/share/filebeat/data/registry
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.169128 registrar.go:253: DBG Registry file updated. 15 states written.
Dec 01 08:47:53 hyrb dockerd[10369]: 2017/12/01 08:47:53.637285 log.go:85: DBG End of file reached: /var/lib/docker/containers/0ce25642d8009f26fe29da0ff5123b5877661e06f435e118854e344abebfaf5f/0ce25642d8009f26fe29da0ff5123b5877661e06f435e11885
Dec 01 08:47:55 hyrb dockerd[10369]: 2017/12/01 08:47:55.116342 log.go:85: DBG End of file reached: /var/lib/docker/containers/41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325/41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf
Dec 01 08:47:57 hyrb dockerd[10369]: 2017/12/01 08:47:57.541338 log.go:85: DBG End of file reached: /var/lib/docker/containers/d7fdf40887de244536e24112b8cdb24222f46ef9421e30024aeba85bb813e333/d7fdf40887de244536e24112b8cdb24222f46ef9421e30024a
Dec 01 08:47:59 hyrb dockerd[10369]: 2017/12/01 08:47:59.114992 prospector.go:140: DBG Run prospector
Dec 01 08:47:59 hyrb dockerd[10369]: 2017/12/01 08:47:59.115035 prospector.go:136: DBG Start next scan
Dec 01 08:47:59 hyrb dockerd[10369]: 2017/12/01 08:47:59.116727 add_docker_metadata.go:124: DBG Container not found: 41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325

```

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 1, 2017, 9:24am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/2 "2017-12-01T09:24:33Z")

</div>

Hi @benben,

Thank you for reporting this, could you please share the output of the following command?

```auto
docker events --filter container=41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325 --since 2017-01-01T10:00:00.999999999

```

---

<div class="post-metadata">

### Author: ![benben](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benben/32/6660_2.png) [@benben](https://discuss.elastic.co/u/benben)
#### Post date: [December 1, 2017, 9:44am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/3 "2017-12-01T09:44:21Z")

</div>

```auto
$ docker events --filter container=41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325 --since 2017-01-01T10:00:00.999999999
2017-12-01T09:01:14.806436716Z container kill 41b27667b48a4b5f274479523bc4c1123af0ef27df667324cf8a15111b16f325 (com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true, image=nginx:latest, maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=nginx, signal=1)

```

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 1, 2017, 9:59am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/4 "2017-12-01T09:59:23Z")

</div>

This looks like a bug, we should be ignoring kill events, as they carry many signals, not all of them kill the container 🙂

Thanks for reporting, I just opened a PR fixing this: [https://github.com/elastic/beats/pull/5788](https://github.com/elastic/beats/pull/5788)

I'm sorry for the inconvenience, once merged it will make it into the next release window, let me know if you need anything before, we can probably provide snapshot image with the patch

Best regards

---

<div class="post-metadata">

### Author: ![benben](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benben/32/6660_2.png) [@benben](https://discuss.elastic.co/u/benben)
#### Post date: [December 1, 2017, 10:00am UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/5 "2017-12-01T10:00:59Z")

</div>

Sounds awesome. Thank you! When is the next release scheduled? And can I use already the 6.1.x container of filebeat?

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [December 1, 2017, 3:15pm UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/6 "2017-12-01T15:15:36Z")

</div>

It should make it both to next minor and patch versions (6.1.0 and 6.0.1). I would say you can expect a new release soon, in the following days/weeks.

Best regards

---

<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: [December 29, 2017, 3:15pm UTC](https://discuss.elastic.co/t/filebeats-docker-metadata-watcher-losing-container-from-its-list-somehow/109897/7 "2017-12-29T15:15:43Z")

</div>

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