Hi,
I need to calculate delta consumption from a stream of events generated by multiple devices uniquely identified by an ID.
Based on some other forums i could see this is possible using Logstash Aggregate filter
Here is my attempt but unsuccessful to calculate delta between two readings for every device.
filter {
aggregate {
task_id => "%{uniquedeviceid}"
code => "
map['next'] ||= 0 ;
map['next'] -= event.get('reading');
event.set('delta', (map['next'] - event.get('reading')))"
timeout_task_id_field => "uniquedeviceid"
}
Need some help in getting towards the solution
I need to calculate
delta = Current Reading - Previous Reading