# How logstash receive multiple topics from kafka

**URL:** <https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605>\
**Category:** Logstash\
**Created:** [June 18, 2020, 9:06am UTC](https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605 "2020-06-18T09:06:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lan\_Lynn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lan_lynn/32/53910_2.png) [@Lan\_Lynn](https://discuss.elastic.co/u/Lan_Lynn)\
**Post date:** [June 18, 2020, 9:06am UTC](https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605/1 "2020-06-18T09:06:24Z")

</div>

I'm trying to use logstash to receive data from kafka. I'm having this configurations in Kafka below, two topics and one groupID.

```auto
 "DeviceTopic": "device", //Topic for device-gruoped messages
 "TaskTopic": "task", //Topic for task-grouped messages
 "GroupId": "MGI-OUTTLER"

```

I want to know how to write the logstash configuration to enable this? I've been test this below but it can't work. I can't find a reference to tell how to configure it correctly.

```auto
input { 
    kafka {
    id => "test1"
	topics => "device"
	group_id => "MGI-OUTTLER"
  }
	kafka {
    id => "test2"
	topics => "task"
	group_id => "MGI-OUTTLER"
  }
 }

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [June 18, 2020, 10:48am UTC](https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605/2 "2020-06-18T10:48:11Z")

</div>

> **[Kafka input plugin | Logstash Plugins](https://www.elastic.co/docs/reference/logstash/plugins/plugins-inputs-kafka)**
>
> A component of the kafka integration plugin, Integration version: v12.1.0, Released on: 2026-03-18, Changelog. For questions about the plugin, open a...

Topic can be an array. When I tested this before I think I did something like this.

```auto
input {
    kafka {
      topics => ["device", "task"]
      group_id => "MGI-OUTTLER"
  }
}

```

To separte them in filter/output you would use an if statement.

```auto
if [kafka][topic] == "device" {

}

```

---

<div class="post-metadata">

**Author:** ![Lan\_Lynn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lan_lynn/32/53910_2.png) [@Lan\_Lynn](https://discuss.elastic.co/u/Lan_Lynn)\
**Post date:** [June 19, 2020, 6:51am UTC](https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605/3 "2020-06-19T06:51:47Z")

</div>

Thank you so much！  
I've tried this, and it shows "Successufully subscribed to topics: device, tasks". Does that means the conversation is started correctly? Because I still can't get any message, but I guess it's more because of the software that I use to send the Kafka message. There might be some issue with its kafka message.  
Anyway, thanks a lot!

---

<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:** [July 17, 2020, 6:51am UTC](https://discuss.elastic.co/t/how-logstash-receive-multiple-topics-from-kafka/237605/4 "2020-07-17T06:51:49Z")

</div>

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