In Consul you can have many agents as servers or clients. Amongst all servers one is chosen as the leader. From the agent\'s point of view, how does it know it is the leader?
Consul uses RAFT Consensus Algorithm. This link below helps you understand how raft works visually (Which also shows how a member is elected as leader step by step).
Reference is from official consul documentation: https://www.consul.io/docs/internals/consensus.html