# Filebeat exclude\_files is not working as expected for windows

**URL:** https://discuss.elastic.co/t/filebeat-exclude-files-is-not-working-as-expected-for-windows/336829
**Category:** Beats
**Tags:** filebeat
**Created:** [June 25, 2023, 6:42am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-is-not-working-as-expected-for-windows/336829 "2023-06-25T06:42:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![junly](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@junly](https://discuss.elastic.co/u/junly)
#### Post date: [June 25, 2023, 6:42am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-is-not-working-as-expected-for-windows/336829/1 "2023-06-25T06:42:05Z")

</div>

Elastic Filebeat 8.7.0  
file path "d:\log\LuceneSOA\排序搜索结果\2023-06-21.txt", Exclude txt files dated under the file but not working  
the regexp was verified with `regex101.com `

filebeat.yml input

```auto
filebeat.inputs:    
- type: filestream 
  paths:
    - d:\log\*.txt
    - d:\log\*\*.txt
    - d:\log\*\*\*.txt
  tail_lines: true
  tags: ["app", "hb"]
  exclude_lines: ["^-"]
  exclude_files: 
    - '\w+\:\\\\\w+\\\\\w+\\\\排序搜索结果\\.*txt'
    - 'd:\log\LuceneSOA\排序搜索结果\*.txt'
    - '^d:\log\LuceneSOA'
    - '^d:\\log\\LuceneSOA'
    - '.*排序搜索结果.*'
    - '.*[\u6392][\u5e8f][\u641c][\u7d22][\u7ed3][\u679c]/.*txt'
    - '.*排序搜索结果.*.txt$'
    - '.*[\u6392][\u5e8f][\u641c][\u7d22][\u7ed3][\u679c].*.txt$'
    - '^\w+\:\\\w+\\\w+\\排序搜索结果\\\d{4}\-\d{2}\-\d{2}\.\w+'
    - '\w+\:\\\w+\\LuceneSOA'
    - '\w+\:\\\w+\\LuceneSOA\\.*'
    - '\w+\:\\\\\w+\\\\LuceneSOA\\.*'
    - '\w+\:\\\\\w+\\\\\w+\\\\[\u6392][\u5e8f][\u641c][\u7d22][\u7ed3][\u679c]'
    - '\w+\:\\\\\w+\\\\\w+\\\\[\u6392][\u5e8f][\u641c][\u7d22][\u7ed3][\u679c]\\\\.*txt'
    - '\w+\:\\\w+\\\w+\\[\u6392][\u5e8f][\u641c][\u7d22][\u7ed3][\u679c]\\.*txt'
    
  encoding: utf8
  ignore_older: 2h
  fields_under_root: true
  multiline.type: pattern
  multiline.pattern: '^\[\d{4}-\d{1,2}-\d{1,2}|^\d{4}/\d{1,2}/\d{1,2}|^\d{4}-\d{1,2}-\d{1,2}'
  multiline.negate: true
  multiline.match: after

```

Any help would be much appreciated.  
Thanks,

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [June 25, 2023, 5:19pm UTC](https://discuss.elastic.co/t/filebeat-exclude-files-is-not-working-as-expected-for-windows/336829/2 "2023-06-25T17:19:28Z")

</div>

Welcome to the community junly.  
Maybe this is an issue: ` ignore_older: 2h` - do not read files older than 2h

Also simplify, just for test purpose.  
`multiline.pattern: '^\[\d{4}-*'`  
Latter, you can add more from the line your full pattern.

I think you have too many `exlude_files`. Paths are only `d:\log\*`, don't see any point of `\w+\:\\\w+\\LuceneSOA'`

When things are not working in the current logic, make the simplest yml then go step by step, make more and more complex.

---

<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 23, 2023, 7:20pm UTC](https://discuss.elastic.co/t/filebeat-exclude-files-is-not-working-as-expected-for-windows/336829/3 "2023-07-23T19:20:17Z")

</div>

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