# Filebeat exclude\_linex regex to exclude all lines not containing error

**URL:** <https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388>\
**Category:** Beats\
**Created:** [August 18, 2016, 6:49pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388 "2016-08-18T18:49:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 18, 2016, 6:49pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/1 "2016-08-18T18:49:06Z")

</div>

Anyone can help me with the regex to ignore all lines that doesnt contain error or Error at any position of the line?

---

<div class="post-metadata">

**Author:** ![monica](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monica/32/3696_2.png) [@monica](https://discuss.elastic.co/u/monica)\
**Post date:** [August 18, 2016, 8:22pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/2 "2016-08-18T20:22:22Z")

</div>

In the latest version of Filebeat there are two options to solve this issue:

- using processors

```auto
processors:
  or:
    - when.contains.message: "Error"
    - when.contains.message: "error"

```

- using exclude

```auto
exclude_lines: ["*error*", "*Error*"]

```

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 19, 2016, 2:33pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/3 "2016-08-19T14:33:30Z")

</div>

correcting the regexes here:

```auto
exclude_lines: ['.*error.*', '.*Error.*']

```

Btw. regex matching searches for sub-string matching the regular expression. That is, this config should perform much better:

```auto
exclude_lines: ['[eE]rror']

```

Tip: do not use double quotes `"` for regexes.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 20, 2016, 4:42pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/4 "2016-08-20T16:42:03Z")

</div>

> [@steffens](#):
>
> exclude\_lines: ['[eE]rror']

but that would exclude all lines containing eError. how do i negate it? I just want to send lines with error messages.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 22, 2016, 9:52am UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/5 "2016-08-22T09:52:56Z")

</div>

for log lines only having content `[eE]rror`, use the `include_lines` setting. When using processors, a `not` filter negating a predicate also exists.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 22, 2016, 9:54am UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/6 "2016-08-22T09:54:20Z")

</div>

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:** [September 8, 2016, 6:49pm UTC](https://discuss.elastic.co/t/filebeat-exclude-linex-regex-to-exclude-all-lines-not-containing-error/58388/7 "2016-09-08T18:49:09Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
