# FIlebeat with services inside of docker compose via autodiscover

**URL:** https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886
**Category:** Beats
**Tags:** filebeat
**Created:** [October 31, 2018, 4:35pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886 "2018-10-31T16:35:50Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![krainboltgreene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krainboltgreene/32/37174_2.png) [@krainboltgreene](https://discuss.elastic.co/u/krainboltgreene)
#### Post date: [October 31, 2018, 4:35pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/1 "2018-10-31T16:35:50Z")

</div>

Alright, so lets say I have these services:

```auto
services:
  redis:
    ...
  filebeat:
    ...

```

And this filebeat configuration:

```auto
filebeat.autodiscover:
  providers:
    - type: docker
      templates:
        - config:
          - type: docker
            containers.ids:
              - "${data.docker.container.id}"
        - condition:
            contains:
              docker.container.image: redis
          config:
            - module: redis
              log:
                input:
                  type: docker
                  containers.ids:
                    - "${data.docker.container.id}"
              slowlog:
                var.hosts: ["${data.host}:${data.port}"]

```

It's my understanding that I should see information related to redis come from filebeat? That it'll automatically figure out the logging situation across docker containers?

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [October 31, 2018, 4:48pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/2 "2018-10-31T16:48:21Z")

</div>

Hi @krainboltgreene and welcome 🙂

You are right, with this configuration filebeat will automatically enable the `redis` module to collect the logs from your redis containers (if their container image contains "`redis`" 🙂 ).

Take into account that for that filebeat needs access to the docker log files, take a look to the documentation about running [filebeat on docker](https://www.elastic.co/guide/en/beats/filebeat/6.4/running-on-docker.html).

---

<div class="post-metadata">

### Author: ![krainboltgreene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krainboltgreene/32/37174_2.png) [@krainboltgreene](https://discuss.elastic.co/u/krainboltgreene)
#### Post date: [October 31, 2018, 4:49pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/3 "2018-10-31T16:49:10Z")

</div>

Thanks so much for the response! I'll see what I can do to figure out why I'm not getting any information.

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [October 31, 2018, 4:59pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/4 "2018-10-31T16:59:30Z")

</div>

Oh 🤔 does filebeat has access to the docker socket and to docker log files? can you see any error in filebeat logs?

---

<div class="post-metadata">

### Author: ![krainboltgreene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krainboltgreene/32/37174_2.png) [@krainboltgreene](https://discuss.elastic.co/u/krainboltgreene)
#### Post date: [October 31, 2018, 5:00pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/5 "2018-10-31T17:00:53Z")

</div>

No errors, but here's my full configuration file if that helps:

> <https://gist.github.com/krainboltgreene/6209955ed4a647e7b936863111c5d62b>

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [October 31, 2018, 5:02pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/6 "2018-10-31T17:02:48Z")

</div>

Can you also share your docker compose file?

---

<div class="post-metadata">

### Author: ![krainboltgreene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krainboltgreene/32/37174_2.png) [@krainboltgreene](https://discuss.elastic.co/u/krainboltgreene)
#### Post date: [October 31, 2018, 5:04pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/7 "2018-10-31T17:04:05Z")

</div>

@jsoriano I've updated the gist with that file.

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [October 31, 2018, 5:37pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/8 "2018-10-31T17:37:41Z")

</div>

I have reduced the config to this and it works for redis:

docker-compose.yml:

```auto
version: "3.3"
  
services:
  redis:
    image: redis:4.0.11-alpine
    healthcheck:
      test: redis-cli ping
      interval: 30s
      timeout: 10s
      retries: 3

  filebeat:
    image: docker.elastic.co/beats/filebeat:6.4.2
    command:
      - "-e"
      - "--strict.perms=false"
    restart: always
    user: root
    volumes:
      - "./filebeat.yml:/usr/share/filebeat/filebeat.yml:ro"
      - "/var/run/docker.sock:/var/run/docker.sock"
      # This is needed for filebeat to load container log path as specified in filebeat.yml
      - "/var/lib/docker/containers/:/var/lib/docker/containers/:ro"
      # This is needed for filebeat to load logs for system and auth modules
      - "/var/log/:/var/log/:ro"

```

filebeat.yml:

```auto
filebeat.autodiscover:
  providers:
    - type: docker
      templates:
        - condition:
            contains:
              docker.container.image: redis
          config:
            - module: redis
              log:
                enabled: true
                input:
                  type: docker
                  containers.ids:
                    - "${data.docker.container.id}"
              slowlog:
                enabled: true
                var.hosts: ["${data.host}:${data.port}"]

output.console:
  pretty: true

```

Notice that I have added the `-e` flag to filebeat, this will make it to log to standard output, what is recommended for deployments in docker, and in this case it will also help you to see possible errors.

I have also seen that you have configured `elasticsearch:9200` as output, and the `elasticsearch` service is configured with `--transport.host=127.0.0.1`. Is it possible that filebeat cannot connect with elasticsearch? You should be able to see it if you add the `-e` flag mentioned before. If that is the case try to remove this flag, or set it to `--transport.host=0.0.0.0`.

If this doesn't help and my example doesn't work for you (it should print the events to stdout), check that your docker daemon is configured with the `json-file` logging driver. You can check it with `docker info`.

---

<div class="post-metadata">

### Author: ![krainboltgreene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krainboltgreene/32/37174_2.png) [@krainboltgreene](https://discuss.elastic.co/u/krainboltgreene)
#### Post date: [October 31, 2018, 6:41pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/9 "2018-10-31T18:41:09Z")

</div>

-e is fantastic. There's a whole swath of things for me to work on apparently. Also, I'm now getting redis data!

---

<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: [November 28, 2018, 6:41pm UTC](https://discuss.elastic.co/t/filebeat-with-services-inside-of-docker-compose-via-autodiscover/154886/10 "2018-11-28T18:41:09Z")

</div>

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