# Filebeat in Docker can't output to Kafka

**URL:** <https://discuss.elastic.co/t/filebeat-in-docker-cant-output-to-kafka/208395>\
**Category:** Beats\
**Tags:** docker, filebeat\
**Created:** [November 18, 2019, 10:24pm UTC](https://discuss.elastic.co/t/filebeat-in-docker-cant-output-to-kafka/208395 "2019-11-18T22:24:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pepper\_Pam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepper_pam/32/56455_2.png) [@Pepper\_Pam](https://discuss.elastic.co/u/Pepper_Pam)\
**Post date:** [November 18, 2019, 10:24pm UTC](https://discuss.elastic.co/t/filebeat-in-docker-cant-output-to-kafka/208395/1 "2019-11-18T22:24:15Z")

</div>

I'm trying to use filebeat in Docker to read log files from local machine and output to Kafka. But it doesn't work properly, doesn't output any message to Kafka. And I tested Kafka on my local machine, it works well itself.

**On my local machine, the file and folder structure like this:**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e3f0079554c0467a1d2dc4fdb7ab3a23a54778e3.png)

**The content of Dockerfile like below:**

```auto
FROM docker.elastic.co/beats/filebeat:7.4.2
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chown root:filebeat /usr/share/filebeat/filebeat.yml
USER filebeat

```

**The Content of filebeat.yml like below:**

```auto
#=========================== Filebeat inputs =============================

filebeat.inputs:

- type: log
 
  enabled: true
  # Paths that should be crawled and fetched. Glob based paths.
  paths: 
    - /Users/lachen/Documents/Log-Monitor/nifi-bootstrap-3.log

#----------------------------- Kafka output --------------------------------
output.kafka:
 # 10.133.93.243 is the private ip address of my local machine
 # even though I use localhost as ["localhost:9092"], and it doesn't work properly
  hosts: ["10.133.93.243:9092"]
  topic: pam-filebeat-test2
  partition.round_robin:
    reachable_only: false
  required_acks: 1
  
  compression: gzip
  max_message_bytes: 1000000

```

**1. I build the filebeat image using below command:**  
`docker image build -t filebeat:1.0.2 .`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/5/15d3aaee4d15af9d81b763345bd744cc9441748a.png)

**2. I run the filebeat container using below command**  
`docker container run -u 0 --name filebeat-container filebeat:1.0.2`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/4/64eb3d5cc6e711a8caf95c8688a7e6de2f446a16.png)

**I also tried to run the container using command like below, it doesn't work as well:**  
`docker container run -u 0 -e strict.perms=false --name filebeat-container filebeat:1.0.2`

**3. I check the topic in kafka using below command:**  
`kafka-console-consumer --bootstrap-server localhost:9092 --topic pam-filebeat-test2 --from-beginning`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/3/23f02a3e45ce1ef2859fd7f9b73d8400a7799a1f.png)

**4. add new contents to the logfiles**

```auto
echo "1">>nifi-bootstrap-3.log
echo "2">>nifi-bootstrap-3.log
echo "3">>nifi-bootstrap-3.log

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/b/eb43a622db61d8eee54de6abd994cf33e2e05033.png)

**5. go back and check the kafka, it didn't receive any message from the filebeat.**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/3/33b9bfcd804e13bc9d78410577147ba87b99278a.png)

---

<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 16, 2019, 10:24pm UTC](https://discuss.elastic.co/t/filebeat-in-docker-cant-output-to-kafka/208395/2 "2019-12-16T22:24:17Z")

</div>

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