# Event.get(message).bytesize

**URL:** <https://discuss.elastic.co/t/event-get-message-bytesize/267004>\
**Category:** Logstash\
**Created:** [March 11, 2021, 10:19pm UTC](https://discuss.elastic.co/t/event-get-message-bytesize/267004 "2021-03-11T22:19:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [March 11, 2021, 10:47pm UTC](https://discuss.elastic.co/t/event-get-message-bytesize/267004/2 "2021-03-11T22:47:36Z")

</div>

It is really not a simple question to answer, because it is unclear what you are asking for. If you want the length of the JSON string that will get written to elasticsearch then serialize the event and check the length of the string.

If you want an approximation of the size of the entire event then you could re-purpose some [code](https://github.com/kaspernj/knjrbfw/blob/master/lib/knj/memory_analyzer.rb#L334).

If you want to know how much memory is allocated for an object that will vary between JVMs, and depend on what other objects exist (think string pools).

Note that

```
ruby { code => 'event.set("size", event.to_s.bytesize)' }

```

does not do what you want because event.to\_s does not do what you expect.

---

_[View the full topic](https://discuss.elastic.co/t/event-get-message-bytesize/267004)._
