# Filebeat exclude\_files regex

**URL:** <https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 14, 2022, 10:25am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206 "2022-12-14T10:25:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubham\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_singh/32/96820_2.png) [@Shubham\_Singh](https://discuss.elastic.co/u/Shubham_Singh)\
**Post date:** [December 14, 2022, 10:25am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206/1 "2022-12-14T10:25:38Z")

</div>

I want to exclude all access logs files from the filebeat except 2 service access logs. I'm using the regex but getting error and filebeat start is failing

`exclude_files: ['\/var\/log\/xxx\/.*(?!.*(xxx)).*\/.*(?!.*(xxx)).*-access.log']`

error message

```auto
`ERROR instance/beat.go:989 Exiting: Failed to start crawler: starting input failed: Error while initializing input: error parsing regexp: invalid or unsupported Perl syntax: `(?!` accessing 'filebeat.inputs.0.exclude_files.0' (source:'/etc/filebeat/filebeat.yml')
filebeat[8457]: Exiting: Failed to start crawler: starting input failed: Error while initializing input: error parsing regexp: invalid or unsupported Perl syntax: `(?!` accessing 'filebeat.inputs.0.exclude_files.0' (source:'/etc/filebeat/filebeat.yml')`

```

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [December 14, 2022, 10:44am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206/2 "2022-12-14T10:44:49Z")

</div>

Hi Shubham,

The error states the pattern '(?!' is not supported. I'm assuming you're using ! as not in this case. Have you tried using the negated operator ^, [as per the regex support guide](https://www.elastic.co/guide/en/beats/filebeat/current/regexp-support.html)?

---

<div class="post-metadata">

**Author:** ![Shubham\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_singh/32/96820_2.png) [@Shubham\_Singh](https://discuss.elastic.co/u/Shubham_Singh)\
**Post date:** [December 14, 2022, 12:57pm UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206/3 "2022-12-14T12:57:56Z")

</div>

Tried negated operator but whole words do not work inside of a character class.

example- I don't want to match message-portal in the string but message-list should be matched in this case negate operator is failing.

---

<div class="post-metadata">

**Author:** ![Shubham\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_singh/32/96820_2.png) [@Shubham\_Singh](https://discuss.elastic.co/u/Shubham_Singh)\
**Post date:** [December 20, 2022, 9:49am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206/4 "2022-12-20T09:49:15Z")

</div>

> [@Shubham\_Singh](#):
>
> /var/log/xxx/._(?!._(xxx))._/._(?!._(xxx))._-access.log

The issue still persists any work around for the same can be done

---

<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 17, 2023, 11:50am UTC](https://discuss.elastic.co/t/filebeat-exclude-files-regex/321206/5 "2023-01-17T11:50:14Z")

</div>

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