consul

Consul API, Retrieve services instances list from all nodes


I've explored service catalog, all I can see are the actual Service names, but not each service instance. for e.g using Consul API/CLI, I can only see Service-A, But I prefer to see all instances under it.

How can I get the all services instances from all nodes together?


Solution

  • You can't get this information directly.

    The only way to get an entire list is to write a script that first enumerates the services by name (/v1/catalog/services) and then enumerates the instance by service name (/v1/catalog/service/<service_name>).

    Rinse and repeat.