There are two main problems to resolve: a) events needs to be totally ordered and b) detect concurrent events. Lamport timestamp addresses the total order problem; and vector clock helps to detect concurrent events.
Lamport clocks: https://www.youtube.com/watch?app=desktop&v=cc3vjDHWYx8 ,