Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single API to list all the services - consul cluster

Tags:

consul

Is there a single API to list all the services registered in a consul cluster?

Constraint: ui is disabled.

like image 348
Jithin Pavithran Avatar asked Dec 15 '25 04:12

Jithin Pavithran


1 Answers

That depends, whether you have a single datacenter or no. If yes, then you can use a Consul HTTP API to query all the services in current agent's datacenter. Otherwise you will need to query all the datacenter names first and then query services for exact datacenter.

Here is some example from the documentation:

Simple request

curl https://consul.rocks/v1/catalog/services

will return the services registered in a given datacenter as follows:

{
  "consul": [],
  "redis": [],
  "postgresql": [
    "primary",
    "secondary"
  ]
}
like image 188
Stanislav Avatar answered Dec 16 '25 22:12

Stanislav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!