# Conditional topics not work: since document\_type is deprecated, how to use %{\[type\]} in kafka ouput?

**URL:** <https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499>\
**Category:** Beats\
**Created:** [November 29, 2017, 2:00am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499 "2017-11-29T02:00:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldcodeoberyn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oldcodeoberyn/32/24800_2.png) [@oldcodeoberyn](https://discuss.elastic.co/u/oldcodeoberyn)\
**Post date:** [November 29, 2017, 2:00am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/1 "2017-11-29T02:00:15Z")

</div>

anyway, this %{[type]} is still valid in the filebeat 6.0.0 docs. but it is not working in program. and when I use fields it is also not working for topics, e.g:  
filebeat.prospectors:  
...  
fields:  
log\_topic: test1  
...  
output.kafka:  
...  
topic: '%{[log\_topic]}'

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [November 29, 2017, 2:23pm UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/2 "2017-11-29T14:23:55Z")

</div>

Can you share your complete docs (please use the `</>` button for formatting configs and logs)? The `document_type` setting should still work. Ithink it's the output hardcoding `_type` to `docs`, but `document_type` sets the `type` field.

By default the `fields` setting adds events to the `fields` namespace. You might have to use `topic: '%{[fields.log_topic]}'`.

---

<div class="post-metadata">

**Author:** ![oldcodeoberyn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oldcodeoberyn/32/24800_2.png) [@oldcodeoberyn](https://discuss.elastic.co/u/oldcodeoberyn)\
**Post date:** [November 30, 2017, 8:27am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/3 "2017-11-30T08:27:45Z")

</div>

the doc is in:

- [https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html](https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html)
- [https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-reference-yml.html](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-reference-yml.html)
- the filebeat-reference.yml in rpm

all of them are still recommend %{[type]}. but I test in filebeat 6.0.0, it can not refer to document\_type

and thanks for 'topic: '%{[fields.log\_topic]}'.' it work for me

---

<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:** [November 30, 2017, 6:40pm UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/4 "2017-11-30T18:40:45Z")

</div>

Could you share your full config and logs? Please format them using `</>`.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [December 3, 2017, 9:53am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/5 "2017-12-03T09:53:19Z")

</div>

`document_type` was removed in 6.0 after it was deprecated in 5.5: [https://github.com/elastic/beats/pull/4204](https://github.com/elastic/beats/pull/4204)

`fields` should be used for that now. We should fix our docs here ☹

@oldcodeoberyn Want to open a Github issue for it?

---

<div class="post-metadata">

**Author:** ![oldcodeoberyn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oldcodeoberyn/32/24800_2.png) [@oldcodeoberyn](https://discuss.elastic.co/u/oldcodeoberyn)\
**Post date:** [December 13, 2017, 1:12am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/6 "2017-12-13T01:12:17Z")

</div>

🕶 originally, I want to open a github issue before I opened this discussion. but it is already 10 day pass, I think you have been fix it already in doc?

---

<div class="post-metadata">

**Author:** ![Suny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suny/32/22082_2.png) [@Suny](https://discuss.elastic.co/u/Suny)\
**Post date:** [December 15, 2017, 9:15am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/7 "2017-12-15T09:15:05Z")

</div>

Hi, this is a config that works for us:

```
filebeat.prospectors:
- type: log
  paths:
  - /var/log/log1.log
  fields:
    kafka_topic: elk1
  fields_under_root: true
- type: log
  paths:
  - /var/log/log2.log
  fields:
    kafka_topic: elk2
  fields_under_root: true
output.kafka:
  hosts: ["kafka1:9092", "kafka2:9092", "kafka3:9092"]
  topic: '%{[kafka_topic]}'

```

It should also work without the fields\_under\_root thing, which would look like below - this is untested, however:

```
filebeat.prospectors:
- type: log
  paths:
  - /var/log/log1.log
  fields:
    kafka_topic: elk1
- type: log
  paths:
  - /var/log/log2.log
  fields:
    kafka_topic: elk2
output.kafka:
  hosts: ["kafka1:9092", "kafka2:9092", "kafka3:9092"]
  topic: '%{[fields.kafka_topic]}'

```

I agree with @oldcodeoberyn that this should be fixed soon, it's really misleading and many people are running into it.

---

<div class="post-metadata">

**Author:** ![Suny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suny/32/22082_2.png) [@Suny](https://discuss.elastic.co/u/Suny)\
**Post date:** [December 15, 2017, 9:25am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/8 "2017-12-15T09:25:54Z")

</div>

It't not fixed yet on [https://www.elastic.co/guide/en/beats/filebeat/6.1/kafka-output.html#\_literal\_topic\_literal](https://www.elastic.co/guide/en/beats/filebeat/6.1/kafka-output.html#_literal_topic_literal) or [https://www.elastic.co/guide/en/beats/filebeat/6.0/kafka-output.html#\_literal\_topic\_literal](https://www.elastic.co/guide/en/beats/filebeat/6.0/kafka-output.html#_literal_topic_literal). There's a pull request [https://github.com/elastic/beats/pull/5867](https://github.com/elastic/beats/pull/5867) .

---

<div class="post-metadata">

**Author:** ![dedemorton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dedemorton/32/84409_2.png) [@dedemorton](https://discuss.elastic.co/u/dedemorton)\
**Post date:** [December 15, 2017, 5:57pm UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/9 "2017-12-15T17:57:10Z")

</div>

The PR has been merged into the master branch and should show up in the other branches sometime today. We require every PR to be reviewed before it's merged...hence the delay. Thanks for your patience.

---

<div class="post-metadata">

**Author:** ![Suny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suny/32/22082_2.png) [@Suny](https://discuss.elastic.co/u/Suny)\
**Post date:** [December 19, 2017, 3:06pm UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/10 "2017-12-19T15:06:20Z")

</div>

Cool, it's fixed, 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:** [December 20, 2017, 2:00am UTC](https://discuss.elastic.co/t/conditional-topics-not-work-since-document-type-is-deprecated-how-to-use-type-in-kafka-ouput/109499/11 "2017-12-20T02:00:19Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
