# Filebeat kafka out plugin error when configuring multiple topics using regex

**URL:** <https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 16, 2020, 8:00am UTC](https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264 "2020-01-16T08:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamabug](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@iamabug](https://discuss.elastic.co/u/iamabug)\
**Post date:** [January 16, 2020, 8:00am UTC](https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264/1 "2020-01-16T08:00:23Z")

</div>

I am trying to output file to different topic using regex, but the following config does not work:

```
filebeat.inputs:
- type: log
  enabled: true
  paths:
      - ~/1.log

output.kafka:
    enabled: true
    hosts: ["localhost:9092"]
    topic: "default"
    codec.format:
        string: '%{[message]}'
    topics:
        - topic: "type1"
          when.regexp.message: "\[type1\].*"
        - topic: "type2"
          when.regexp.message: "\[type2\].*"

```

the error message is

```
Exiting: error loading config file: yaml: line 20: found unknown escape character

```

OS: Mac  
filebeat version: 6.5, 7.5  
Kafka version : 2.3.1

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [January 16, 2020, 8:13pm UTC](https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264/2 "2020-01-16T20:13:01Z")

</div>

When I tried reproducing this with your posted configuration, I got a similar error but on a different line:

```auto
Exiting: error loading config file: yaml: line 15: found unknown escape character

```

To fix that I used single quotes `'` for quoting the regular expressions on line 15 and 17. After I did that, I was able to start up Filebeat without any YAML validation errors.

Your error messages mentions line 20 but the posted configuration does not have 20 lines in it.

---

<div class="post-metadata">

**Author:** ![iamabug](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@iamabug](https://discuss.elastic.co/u/iamabug)\
**Post date:** [January 16, 2020, 10:11pm UTC](https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264/3 "2020-01-16T22:11:10Z")

</div>

sorry, when I copy the config I remove some comments. And single quote does work, thanks very much.

---

<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:** [February 13, 2020, 10:11pm UTC](https://discuss.elastic.co/t/filebeat-kafka-out-plugin-error-when-configuring-multiple-topics-using-regex/215264/4 "2020-02-13T22:11:10Z")

</div>

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