Search code examples
consul

when consul node run on server mode, what endpoint /v1/agent/services will return?


I find my server node's endpoint >/v1/agent/services returns majority of services, but not all the services, anyone knows why ?


Solution

  • The visibility of services will depend on which API endpoint you're using.

    Consul intends for services to be registered against a Consul client agent which is running on the same host as the deployed service (using the /v1/agent/service/register endpoint). The services registered with each agent in the data center are aggregated to form the service catalog (https://www.consul.io/docs/architecture/anti-entropy#catalog).

    The /v1/agent/services endpoint only returns services which have been registered against the specific agent with which you are communicating. In contrast, the /v1/catalog/services endpoint returns an aggregated list of all services which have been registered every agent across the data center. If you query this endpoint, you will receive a list of all services registered with Consul.