# Remove the pri-tag from rsyslog messages

**URL:** <https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161>\
**Category:** Logstash\
**Created:** [August 21, 2019, 4:40pm UTC](https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161 "2019-08-21T16:40:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwenger](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@dwenger](https://discuss.elastic.co/u/dwenger)\
**Post date:** [August 21, 2019, 4:40pm UTC](https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161/1 "2019-08-21T16:40:13Z")

</div>

Hi,

I'm trying to put postfix logs to elasticsearch.

I'm stuck with parsing the pri-tag - in fact, I want to remove it from the message.

Here's a line from logs being sent:

\<22\>Aug 21 18:34:14 mailserver postfix/qmgr[1842]: 37C0E2D1C: removed

I want to remove that number \<22\>

I've found this thread [Remove part of message string](https://discuss.elastic.co/t/remove-part-of-message-string/66809) but even when adding a gsub like

mutate {  
gsub =\> ["message", "\<22\>", ""]  
}

it doesn't work.

Any help is appreciated

Regards

Daniel

---

<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:** [August 21, 2019, 5:45pm UTC](https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161/2 "2019-08-21T17:45:06Z")

</div>

With a simple configuration like

```
 input { generator { count => 1 lines => ['<22>Aug 21 18:34:14 mailserver postfix/qmgr[1842]: 37C0E2D1C: removed' ] } }
filter {
    mutate { gsub => ["message", "<22>", ""] }
}
output { stdout { codec => rubydebug { metadata => false } } }

```

It most certainly does work

```
   "message" => "Aug 21 18:34:14 mailserver postfix/qmgr[1842]: 37C0E2D1C: removed",

```

Although I would recommend

```
mutate { gsub => ["message", "^<\d+>", ""] }
```

---

<div class="post-metadata">

**Author:** ![dwenger](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@dwenger](https://discuss.elastic.co/u/dwenger)\
**Post date:** [August 21, 2019, 5:57pm UTC](https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161/3 "2019-08-21T17:57:35Z")

</div>

thanks a lot for your swift reply.

I do not understand why your mutate statement works while mine didn't.

---

<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 18, 2019, 5:57pm UTC](https://discuss.elastic.co/t/remove-the-pri-tag-from-rsyslog-messages/196161/4 "2019-09-18T17:57:47Z")

</div>

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