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.
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]} ..."
Thank you for your reply.
How can I store the variable "[mem][used_p]" on metadata "%{[@metadata][mem_used_pct]}"?
Use a ruby filter. Something like this might work for Logstash pre-5.0:
ruby {
code => "
event['@metadata']['mem_used_pct'] = (event['mem']['used_p'] * 100).to_i
"
}
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
If the service doesn't start it should tell you why in the logs.