What I am trying to do is calculate the % of packets that didn't make it ( % of Packets Lost) but no matter the figures input in Packets Sent / Received, packetloss1 is always equals to 0 and I'm unsure why that is
I suspect [packets-received] and [packets-sent] are integers. Try
code => '
received = event.get("[packets-received]")
sent = event.get("[packets-sent]")
if sent and received
event.set("[json][event][packetlosspercentage]", 100 * (1.0 - received.to_f / sent.to_f))