Added algorithm that extracts the events to be sent to the local agent.