# Ruby : Remove event

**URL:** https://discuss.elastic.co/t/ruby-remove-event/142479
**Category:** Logstash
**Created:** [August 1, 2018, 6:44am UTC](https://discuss.elastic.co/t/ruby-remove-event/142479 "2018-08-01T06:44:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Pierre2](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pierre2](https://discuss.elastic.co/u/Pierre2)
#### Post date: [August 1, 2018, 6:44am UTC](https://discuss.elastic.co/t/ruby-remove-event/142479/1 "2018-08-01T06:44:13Z")

</div>

Hello !

I know that it is possible to remove fields from one event thanks to "event.remove('field')".

I want to know if there is a way to remove the complete event and not one or two fields.

My probleme is that I have two events type and I use the aggregate plugin to get some fields from one event and some from the other. I want to push the map as event on timeout and delete the two event that serves me to build the finale event.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [August 1, 2018, 6:58am UTC](https://discuss.elastic.co/t/ruby-remove-event/142479/2 "2018-08-01T06:58:16Z")

</div>

> I want to know if there is a way to remove the complete event and not one or two fields.

See the example in the ruby filter docs:

```plaintext
filter {
  ruby {
    # Cancel 90% of events
    code => "event.cancel if rand <= 0.90"
  }
}

```

---

<div class="post-metadata">

### Author: ![Pierre2](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pierre2](https://discuss.elastic.co/u/Pierre2)
#### Post date: [August 1, 2018, 8:48am UTC](https://discuss.elastic.co/t/ruby-remove-event/142479/3 "2018-08-01T08:48:41Z")

</div>

I works 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: [August 29, 2018, 8:48am UTC](https://discuss.elastic.co/t/ruby-remove-event/142479/4 "2018-08-29T08:48:45Z")

</div>

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