Filter a msg.payload

Using the Unifi Node and I need to understand how to filter a msg.payload please, for example filter the last five alarms/alerts. Thanks in advance for any guidance...

So in the Unifi UI it has Admin Admin username log in from 1.1.1.1 5:06 pm 09/25/2021 so I would like to reproduce the last 5 alerts in the same format.

Example Output

[[{"_id":"61319dae33f1aa1ff4a97c96","ip":"1.1.1.1","admin":"Admin[nameofuser]","site_id":"5dd35c62e9d29101752c640d","is_admin":true,"key":"EVT_AD_Login","subsystem":"","time":1630641582993,"datetime":"2021-09-03T03:59:42Z","msg":"Admin[nameofuser] log in from 1.1.1.1"},{"_id":"61319dae33f1aa1ff4a97c95","ip":"1.1.1.1","admin":"Admin[nameofuser]","site_id":"5dd35c62e9d29101752c640d","is_admin":true,"key":"EVT_AD_Login","subsystem":"","time":1630641582891,"datetime":"2021-09-03T03:59:42Z","msg":"Admin[nameofuser] log in from 1.1.1.1"},{"_id":"61319dae33f1aa1ff4a97c94","ip":"1.1.1.1","admin":"Admin[nameofuser]","site_id":"5dd35c62e9d29101752c640d","is_admin":true,"key":"EVT_AD_Login","subsystem":"","time":1630641582864,"datetime":"2021-09-03T03:59:42Z","msg":"Admin[nameofuser] log in from 1.1.1.1"},{"_id":"61319d5a33f1aa1ff4a97c93","ip":"1.1.1.1","admin":"Admin[nameofuser]","site_id":"5dd35c62e9d29101752c640d","is_admin":true,"key":"EVT_AD_Login","...

It should be easy enough in a function node using the array 'length' and 'slice' methods. Get the count of array items, subtract 5 from it and slice the array using count-5

If you are unclear about the 'length; and 'slice' methods, take a look at
https://www.w3schools.com/jsref/jsref_length_array.asp
https://www.w3schools.com/jsref/jsref_slice_array.asp