# Nomad filebeat autodiscover seems to ignore template's condition

**URL:** https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985
**Category:** Beats
**Tags:** filebeat
**Created:** [December 26, 2023, 7:45pm UTC](https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985 "2023-12-26T19:45:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Yuri\_Nakshin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuri_nakshin/32/130335_2.png) [@Yuri\_Nakshin](https://discuss.elastic.co/u/Yuri_Nakshin)
#### Post date: [December 26, 2023, 7:45pm UTC](https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985/1 "2023-12-26T19:45:22Z")

</div>

Hi,  
We have this setup

```auto
filebeat.autodiscover:
  providers:
    - type: nomad
      node: {{ env "node.unique.name" }}
      scope: node
      address: <nomad-cluster-address>
      templates:
        - condition:
           not:
              contains:
                nomad.task.name: filebeat
          config:
            - type: log
              paths:
                - /node-logs/$${data.nomad.allocation.id}/alloc/logs/$${data.meta.nomad.task.name}.stdout.*
                - /node-logs/$${data.nomad.allocation.id}/alloc/logs/$${data.meta.nomad.task.name}.stderr.*

```

As I understand, this should prevent filebeat from harvesting the logs from the tasks containing 'filebeat' in their names.

However, when I take a look at the filebeat registry, I see a lot of log files from those tasks. Like

```auto
{"_key":"filebeat::logs::native::4386819-66305","prev_id":"","source":"/node-logs/08599431-b9c8-21c0-5fca-33a82fbaf234/alloc/logs/filebeat.stdout.0","timestamp":[754348773,1703599823],"ttl":-1,"id":"native::4386819-66305","offset":9,"type":"log","FileStateOS":{"inode":4386819,"device":66305},"identifier_name":"native"}

```

Am I excluding these logs in a wrong way?  
Thanks!

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [December 27, 2023, 12:56am UTC](https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985/2 "2023-12-27T00:56:57Z")

</div>

Hi @Yuri_Nakshin Welcome to the community...

Not sure if just cut-n-paste or if this is the issue...

```auto
      templates:
        - condition:
           not: << Here indented incorrectly
              contains:
                nomad.task.name: filebeat

```

Should be

```auto
      templates:
        - condition:
            not: 
              contains:
                nomad.task.name: filebeat

```

Unfortunately I do not have a Nomad cluster to test on.  
Nomad is also tech preview so be carefull support / functionality could change.

---

<div class="post-metadata">

### Author: ![Yuri\_Nakshin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuri_nakshin/32/130335_2.png) [@Yuri\_Nakshin](https://discuss.elastic.co/u/Yuri_Nakshin)
#### Post date: [December 27, 2023, 12:31pm UTC](https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985/3 "2023-12-27T12:31:01Z")

</div>

Thanks for your reply, @stephenb  
This must be a cut and paste issue because the config is a valid yaml digested and used by our filebeat without any complains. I just checked our source: "not"'s n is directly under "condition"'s "n" 🙂

---

<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: [January 24, 2024, 2:31pm UTC](https://discuss.elastic.co/t/nomad-filebeat-autodiscover-seems-to-ignore-templates-condition/349985/4 "2024-01-24T14:31:44Z")

</div>

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