# Filebeat topics with 'when' conditions

**URL:** <https://discuss.elastic.co/t/filebeat-topics-with-when-conditions/305054>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [May 18, 2022, 11:20am UTC](https://discuss.elastic.co/t/filebeat-topics-with-when-conditions/305054 "2022-05-18T11:20:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliang](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@juliang](https://discuss.elastic.co/u/juliang)\
**Post date:** [May 18, 2022, 11:20am UTC](https://discuss.elastic.co/t/filebeat-topics-with-when-conditions/305054/1 "2022-05-18T11:20:13Z")

</div>

Hi there,

I have the below defined in my output.kafka section

```auto
    topics:
      - topic: "my-topic"
        when:
          and:
              - equals:
                kubernetes.namespace: "test"
              - has_fields: ["someField"]

```

I get an error with my config  
`Exiting: error initializing publisher: missing or invalid condition`

I then tested just the "has\_fields" condition, i.e.

```auto
    topics:
      - topic: "my-topic"
        when:
              has_fields: ["someField"]

```

And this works perfectly. Does has\_fields not work in conjunction with "and"? If it does, what am I doing wrong?

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:** [June 15, 2022, 1:20pm UTC](https://discuss.elastic.co/t/filebeat-topics-with-when-conditions/305054/2 "2022-06-15T13:20:48Z")

</div>

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