# Exclude Files with YYYY-MM-DD RegEx

**URL:** <https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [July 18, 2019, 1:08pm UTC](https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203 "2019-07-18T13:08:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgeveritt](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bgeveritt](https://discuss.elastic.co/u/bgeveritt)\
**Post date:** [July 18, 2019, 1:08pm UTC](https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203/1 "2019-07-18T13:08:36Z")

</div>

I have the following file structure:

`my-file1.2019-07-16.log`  
`my-file2.2019-07-16.log`  
`my-file.log`

Is there a way to apply a RegEx in the `exclude_files` so that any of the files that have the YYYY-MM-DD pattern are excluded?

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [July 19, 2019, 5:56am UTC](https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203/2 "2019-07-19T05:56:18Z")

</div>

Hi @bgeveritt and welcome to discuss 🙂

Yes, it should be possible to use the `exclude_files` option to exclude files based on a pattern. If this is not working for you, please share your configuration so we can see what can be happening.  
If these are older files, other thing you can try is to use the [`ignore_older`](https://www.elastic.co/guide/en/beats/filebeat/7.2/filebeat-input-log.html#filebeat-input-log-ignore-older) option, that allows to ignore old files.

---

<div class="post-metadata">

**Author:** ![bgeveritt](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bgeveritt](https://discuss.elastic.co/u/bgeveritt)\
**Post date:** [July 20, 2019, 3:52pm UTC](https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203/3 "2019-07-20T15:52:12Z")

</div>

Looks like I sorted it out with the following config:

`exclude_files: ['[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]).log']`

---

<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:** [August 17, 2019, 3:52pm UTC](https://discuss.elastic.co/t/exclude-files-with-yyyy-mm-dd-regex/191203/4 "2019-08-17T15:52:17Z")

</div>

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