# Percentage on E-mail plugin

**URL:** <https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026>\
**Category:** Logstash\
**Created:** [August 15, 2016, 12:33pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026 "2016-08-15T12:33:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafaellamuniz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafaellamuniz/32/8885_2.png) [@rafaellamuniz](https://discuss.elastic.co/u/rafaellamuniz)\
**Post date:** [August 15, 2016, 12:33pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/1 "2016-08-15T12:33:49Z")

</div>

Hello,

I would like to receive the variable "mem.used\_p" from Topbeat as a percentage (something like 99%), like is showed on Kibana.  
However, on the e-mail I receive on decimal format: 0.99

Somebody knows how to convert/fix this?

%{[mem][used\_p]}

Thanks in advance.

---

<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 15, 2016, 8:25pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/2 "2016-08-15T20:25:11Z")

</div>

You can use a ruby filter to transform `[mem][used_p]` in the desired way and store it in a `@metadata` field that won't be shipped to outputs but can be referred to in the email output's `body` option.

```
body => "... %{[@metadata][mem_used_pct]} ..."
```

---

<div class="post-metadata">

**Author:** ![rafaellamuniz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafaellamuniz/32/8885_2.png) [@rafaellamuniz](https://discuss.elastic.co/u/rafaellamuniz)\
**Post date:** [August 16, 2016, 1:55pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/3 "2016-08-16T13:55:11Z")

</div>

Thank you for your reply.

How can I store the variable "[mem][used\_p]" on metadata "%{[@metadata][mem\_used\_pct]}"?

---

<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 16, 2016, 5:02pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/4 "2016-08-16T17:02:44Z")

</div>

Use a ruby filter. Something like this might work for Logstash pre-5.0:

```nohighlight
ruby {
  code => "
    event['@metadata']['mem_used_pct'] = (event['mem']['used_p'] * 100).to_i
  "
}

```

---

<div class="post-metadata">

**Author:** ![rafaellamuniz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafaellamuniz/32/8885_2.png) [@rafaellamuniz](https://discuss.elastic.co/u/rafaellamuniz)\
**Post date:** [August 16, 2016, 6:15pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/6 "2016-08-16T18:15:05Z")

</div>

Looks like I'm doing wrong.

The beats come from Topbeat. To use the ruby I've created a filter file:

more 0002-topbeat-filter.conf

filter{  
if [mem][used\_p]{  
ruby {  
code =\> "event['@metadata']['mem\_used\_pct'] = (event['mem']['used\_p'] \* 100).to\_i"  
}  
}  
}

However, the service don't start now.

I'm sorry, I'm really new on that and felling lost to get the variable as a percente 🙂

---

<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 16, 2016, 6:40pm UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/7 "2016-08-16T18:40:36Z")

</div>

If the service doesn't start it should tell you why in the logs.

---

<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, 2017, 4:43am UTC](https://discuss.elastic.co/t/percentage-on-e-mail-plugin/58026/8 "2017-07-06T04:43:13Z")

</div>


