I'm implementing ruby code through logstash pipeline,Unable to get desired fields created in kibana,what would be right approach to code in order to get desired result?
Want to get CPU % by adding two fileds and divide by no of cores.
ex:((a+b)/n)*100
Below code dosen't work:
ruby {
code => "
userpct = event.get('system.cpu.user.pct')
systempct = event.get('system.cpu.system.pct')
cores = event.get('system.cpu.cores')
cpuusage = (((userpct+systempct)/cores)*100)
if (cpuusage > 20)
event.set('system.cpuusage',cpuusage)
event.set('system.cpu.status','CPUCritical')
else
event.set('system.cpu.status','CPUHealthy')
end
"
}
Image: