# Generate Kafka Topic dynamically with Modules \[Filebeat 7.5\]

**URL:** <https://discuss.elastic.co/t/generate-kafka-topic-dynamically-with-modules-filebeat-7-5/230126>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [April 28, 2020, 9:50am UTC](https://discuss.elastic.co/t/generate-kafka-topic-dynamically-with-modules-filebeat-7-5/230126 "2020-04-28T09:50:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RdrgPorto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rdrgporto/32/13278_2.png) [@RdrgPorto](https://discuss.elastic.co/u/RdrgPorto)\
**Post date:** [April 28, 2020, 9:50am UTC](https://discuss.elastic.co/t/generate-kafka-topic-dynamically-with-modules-filebeat-7-5/230126/1 "2020-04-28T09:50:52Z")

</div>

Hi, everyone

I use **Filebeat** in order to send all my data to **Apache Kafka**. Moreover, I use **parameter fields** in order to generate **Kafka Topic dynamically**. Here you are an example:

```auto
filebeat.inputs:

- type: log
  paths:
    - /var/log/mysql.log
  fields:
   service: mysql

- type: log
  paths:
    - /var/log/apache.log
  fields:
   service: apache

filebeat.config.modules:
  path: ${path.config}/modules.d/system.yml
  reload.enabled: false

logging.level: warning
logging.to_files: true
logging.files:
  path: /var/log/filebeat
  name: filebeat
  keepfiles: 4

output.kafka:
  hosts: ["localhost:9092"]
  topic: "%{[fields.service]}"

```

Is it possible to generate **Kafka Topic** dynamically with **Filebeat Modules**?

Thanks in advance,

Regards 🖖

✏ **Update post**

I achieved it by using **processors** :

```auto
filebeat.inputs:

- type: log
  paths:
    - /var/log/mysql.log
  fields:
   service: mysql

- type: log
  paths:
    - /var/log/apache.log
  fields:
   service: apache

filebeat.config.modules:
  path: ${path.config}/modules.d/system.yml
  reload.enabled: false

processors:
- add_fields:
   when:
    equals:
     event.module: system
   fields:
    service: system

logging.level: warning
logging.to_files: true
logging.files:
  path: /var/log/filebeat
  name: filebeat
  keepfiles: 4

setup.template.enabled: false
setup.ilm.enabled: false

output.kafka:
  hosts: ["localhost:9092"]
  topic: "%{[fields.service]}"

```

---

<div class="post-metadata">

**Author:** ![Camilo\_Diaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/camilo_diaz/32/46512_2.png) [@Camilo\_Diaz](https://discuss.elastic.co/u/Camilo_Diaz)\
**Post date:** [April 29, 2020, 5:09am UTC](https://discuss.elastic.co/t/generate-kafka-topic-dynamically-with-modules-filebeat-7-5/230126/2 "2020-04-29T05:09:05Z")

</div>

I think you will have to set 'auto.create.topics.enable=true' on the broker configuration and on the filebeat output define the topic you want to send/create the logs to.

---

<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 27, 2020, 5:09am UTC](https://discuss.elastic.co/t/generate-kafka-topic-dynamically-with-modules-filebeat-7-5/230126/3 "2020-05-27T05:09:07Z")

</div>

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