# Ruby exception occurred: undefined method \`/'

**URL:** https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method/205389
**Category:** Logstash
**Created:** [October 27, 2019, 5:47pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method/205389 "2019-10-27T17:47:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Luan\_Ph\_m](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luan_ph_m/32/28575_2.png) [@Luan\_Ph\_m](https://discuss.elastic.co/u/Luan_Ph_m)
#### Post date: [October 27, 2019, 5:47pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method/205389/1 "2019-10-27T17:47:33Z")

</div>

```
filter {  
     ruby {
      code => "event.set('test', (event.get('vstorage.space.allocatable') / event.get('vstorage.license.capacity')) * 100)" 
     }
    } 

```

The error is

> [ERROR][logstash.filters.ruby] Ruby exception occurred: undefined method `/' for nil:NilClass  
> [ERROR][logstash.filters.ruby] Ruby exception occurred: nil can't be coerced into Float

I don't know where is not correct.

---

<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: [October 27, 2019, 6:52pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method/205389/2 "2019-10-27T18:52:27Z")

</div>

That is telling you thtat the vstorage.space.allocatable field does not exist. You could wrap your filter in

```
if [vstorage.space.allocatable] and [vstorage.license.capacity] { ... }

```

I assume your field names really do contains periods and they are not nested fields which you would reference as [vstorage][space][allocatable]

---

<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: [November 24, 2019, 6:52pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method/205389/3 "2019-11-24T18:52:31Z")

</div>

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