# Filter message log in logstash

**URL:** <https://discuss.elastic.co/t/filter-message-log-in-logstash/330524>\
**Category:** Logstash\
**Created:** [April 21, 2023, 1:38pm UTC](https://discuss.elastic.co/t/filter-message-log-in-logstash/330524 "2023-04-21T13:38:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kibana\_dev\_iko](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@kibana\_dev\_iko](https://discuss.elastic.co/u/kibana_dev_iko)\
**Post date:** [April 21, 2023, 1:38pm UTC](https://discuss.elastic.co/t/filter-message-log-in-logstash/330524/1 "2023-04-21T13:38:05Z")

</div>

i want to add filter to logstash to convert message to json format  
this is my example

API response \< HTTP 200 - body: {"result": [{"status": {"code": -18, "message": "No permission for the resource"}, "url": "/os/hi"}]}

thank you

---

<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 24, 2023, 2:37am UTC](https://discuss.elastic.co/t/filter-message-log-in-logstash/330524/2 "2023-04-24T02:37:04Z")

</div>

If you want to convert that to JSON then you could use

```
mutate { gsub => ["message", ".*body:", ""] }

```

If you want to parse the resulting JSON then you could use a [json](https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html) filter.

---

<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 22, 2023, 2:37am UTC](https://discuss.elastic.co/t/filter-message-log-in-logstash/330524/3 "2023-05-22T02:37:35Z")

</div>

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