# Logstash, remove all fields that contain a specific value

**URL:** <https://discuss.elastic.co/t/logstash-remove-all-fields-that-contain-a-specific-value/335569>\
**Category:** Logstash\
**Created:** [June 8, 2023, 7:23pm UTC](https://discuss.elastic.co/t/logstash-remove-all-fields-that-contain-a-specific-value/335569 "2023-06-08T19:23:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaismax](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@kaismax](https://discuss.elastic.co/u/kaismax)\
**Post date:** [June 8, 2023, 7:23pm UTC](https://discuss.elastic.co/t/logstash-remove-all-fields-that-contain-a-specific-value/335569/1 "2023-06-08T19:23:15Z")

</div>

how to remove all fields that contain a specific value or reg expression

---

<div class="post-metadata">

**Author:** ![kaismax](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@kaismax](https://discuss.elastic.co/u/kaismax)\
**Post date:** [June 8, 2023, 9:21pm UTC](https://discuss.elastic.co/t/logstash-remove-all-fields-that-contain-a-specific-value/335569/2 "2023-06-08T21:21:54Z")

</div>

solution by me

```auto
ruby
{
code =>
'event.to_hash.keys.each { |k| if k.start_with?("value") then event.remove(k) end }'
}

```

---

<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:** [July 6, 2023, 9:22pm UTC](https://discuss.elastic.co/t/logstash-remove-all-fields-that-contain-a-specific-value/335569/3 "2023-07-06T21:22:32Z")

</div>

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