# Does logstash include some color stripper plug-ins?

**URL:** <https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945>\
**Category:** Logstash\
**Created:** [April 22, 2021, 9:57am UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945 "2021-04-22T09:57:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [April 22, 2021, 9:57am UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/1 "2021-04-22T09:57:10Z")

</div>

like

> **[mattheworiordan/fluent-plugin-color-stripper](https://github.com/mattheworiordan/fluent-plugin-color-stripper)**
>
> Fluentd plugin to strip ANSI color codes from input logs

Can clean the color character output by docker drive.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/d/fd671170087461405fa26f5aa4fe31d336ed352f.png)

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 22, 2021, 2:49pm UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/2 "2021-04-22T14:49:03Z")

</div>

At its [heart](https://github.com/mattheworiordan/fluent-plugin-color-stripper/blob/d0b04940c14a612cb78a8a3a5537e40bb558b9a1/lib/fluent/plugin/out_color_stripper.rb#L36) the color stripper is just gsub, so you can use a [mutate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub) filter.

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [April 23, 2021, 5:09am UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/3 "2021-04-23T05:09:48Z")

</div>

Thanks for your reply, I have never used gsub, do you know how to write regular?

such as

> "message": "\u001b[40m\u001b[1m\u001b[33mwarn\u001b[39m\u001b[22m\u001b[49m: Elastic.Apm[0]\n {PayloadSenderV2} Failed sending events. Following events were not transferred successfully to the server ([http://localhost:8200/](http://localhost:8200/)):\n Elastic.Apm.Metrics.MetricSet"

remove "\u001b[40m\u001b[1m\u001b[33mwarn\u001b[39m\u001b[22m\u001b[49m:"

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cdadabed7b054746209092c92bc0a67c37679e46.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/a/5a673cfc5e4930358bfed66a0e708ae0d9ea775f.png)

I tried it and it didn't work.

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [April 23, 2021, 6:01am UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/4 "2021-04-23T06:01:14Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9b0416ccb730c5db4e50792f348eb75175a065f2.png)

In addition, I found that there are many formats for this color character.  
How to write a universal rules?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 23, 2021, 2:20pm UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/5 "2021-04-23T14:20:40Z")

</div>

The code I linked to include a regexp that can be applied universally.

---

<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:** [May 21, 2021, 2:21pm UTC](https://discuss.elastic.co/t/does-logstash-include-some-color-stripper-plug-ins/270945/6 "2021-05-21T14:21:19Z")

</div>

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