What is the different between /catalog/service and /agent/service/?

Hi @cheyuxuanll,

Consul is designed for services to be registered against a Consul client agent which is running on the same host where a service is deployed. The /v1/agent/service/ endpoints provide a way for you to interact with services which are registered with the specific Consul agent to which you are communicating, and register new services against that agent.

Each Consul agent in the data center submits its registered service information to the Consul servers. The servers aggregate this information to form the service catalog (https://www.consul.io/docs/architecture/anti-entropy#catalog). The /v1/catalog/ endpoints return that aggregated information.

The /catalog/service/ endpoint will contain information that has been successfully submitted by the agents to the servers. If a particular agent is unable to communicate to the servers, it is possible for a service instance to be visible in /agent/service/:id on that agent, but not visible in the output of /catalog/service/:name (edit: this should be service name, not ID) for the rest of the cluster.

See this related answer I provided to a user on StackOverflow for a bit more info https://stackoverflow.com/a/65725360/12384224.

Let me know if you have any other questions.