# Kafka topics configuration example

**URL:** <https://discuss.elastic.co/t/kafka-topics-configuration-example/140911>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [July 20, 2018, 2:28pm UTC](https://discuss.elastic.co/t/kafka-topics-configuration-example/140911 "2018-07-20T14:28:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sykomaniac](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sykomaniac](https://discuss.elastic.co/u/sykomaniac)\
**Post date:** [July 20, 2018, 2:28pm UTC](https://discuss.elastic.co/t/kafka-topics-configuration-example/140911/1 "2018-07-20T14:28:07Z")

</div>

Hi,

Is anyone able to provide me with an example of configuring the topics setting for Kafka output.

I _think_ I can use this to potentially write data points to different topics. E.g. write a mapping of kubernetes --\> pods to a pods topic, kubernetes --\> nodes to a node topic etc.

Thanks

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [July 23, 2018, 9:33am UTC](https://discuss.elastic.co/t/kafka-topics-configuration-example/140911/2 "2018-07-23T09:33:31Z")

</div>

How exactly you would like to separate your data? The processor `add_kubernetes_metadata` adds pod, namespace and labels to your events. ([https://www.elastic.co/guide/en/beats/filebeat/current/add-kubernetes-metadata.html](https://www.elastic.co/guide/en/beats/filebeat/current/add-kubernetes-metadata.html)) Full list of provided fields: [https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields-kubernetes-processor.html](https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields-kubernetes-processor.html)

You could use these fields to send your events to different topics as seen here: [https://www.elastic.co/guide/en/beats/metricbeat/current/kafka-output.html#\_literal\_topic\_literal](https://www.elastic.co/guide/en/beats/metricbeat/current/kafka-output.html#_literal_topic_literal)

To send every event from a namespace to the same topic you could add this to your Kafka output config:

```auto
topic: '%{[fields.kubernetes.namespace]}'

```

---

<div class="post-metadata">

**Author:** ![sykomaniac](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sykomaniac](https://discuss.elastic.co/u/sykomaniac)\
**Post date:** [July 23, 2018, 9:50am UTC](https://discuss.elastic.co/t/kafka-topics-configuration-example/140911/3 "2018-07-23T09:50:51Z")

</div>

Hi @kvch thanks for the reply.

That's exactly my question. I want to make use of the topics configuration item to send messages to different topics based on some of the kubernetes metadata e.g. any node metrics to a node topic, and pod metrics to a pod topic etc. I just wondered if someone could provide a practical example of this configuration as I can't seem to find one to use as a basis.

Thanks

---

<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:** [August 20, 2018, 9:50am UTC](https://discuss.elastic.co/t/kafka-topics-configuration-example/140911/4 "2018-08-20T09:50:56Z")

</div>

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