Consul: HTTP API enhancement to get detailed /v1/catalog/services?

Created on 12 Apr 2016  路  4Comments  路  Source: hashicorp/consul

Is there a way to call /v1/catalog/services and get the contents of /v1/catalog/service/{name} as the array value in the output?

For example, current behavior is:

curl /v1/catalog/services
{"consul":[],"app":[]}
curl /v1/catalog/service/app
[
   {
      "ServicePort" : 4104,
      "Address" : "172.17.0.3",
      "Node" : "671635e38ff0",
      "ServiceAddress" : "172.17.0.5",
      "ServiceName" : "app",
      "ServiceTags" : null,
      "ServiceID" : "app-2c4c225bc31c"
   }
]

is there a way to get this?

curl /v1/catalog/services
{"consul":[
...
],"app":[
   {
      "ServicePort" : 4104,
      "Address" : "172.17.0.3",
      "Node" : "671635e38ff0",
      "ServiceAddress" : "172.17.0.5",
      "ServiceName" : "app",
      "ServiceTags" : null,
      "ServiceID" : "app-2c4c225bc31c"
   }
]}

Most helpful comment

Chiming in with my use case: as a load balancer, I'd like to query all active ServiceAddress & ServicePort in one shot so that round-trips to consul can be minimized.

All 4 comments

Hi @atomantic there's currently not an endpoint that will emit the services in one big data structure like that. It currently takes an initial query to get the list of services followed by a separate query per service. What kind of use case are you thinking the full query would be useful for?

I have a service-status dashboard UI, sort of like the consul UI--but at a higher level and with specific buttons to request verbose status output of each service. I'd like to query the consul catalog to get a list of all services running with their endpoints so I can automate building the list of available services.

I actually need to go up one more level so this might not be the right way to go about it anyway--I'm just investigating now. We have a lot of service stacks and my status dashboard is a UI that displays status of services across product stacks, which means several consul clusters. So in effect, I need to setup a registry of registries to be able to query that and get all the services beneath each stack. I'm looking for the least number of API queries to get that information :)

I see. It sounds like you will be able to get something workable with the current APIs - please let me know if you have any more questions!

Chiming in with my use case: as a load balancer, I'd like to query all active ServiceAddress & ServicePort in one shot so that round-trips to consul can be minimized.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicholasjackson picture nicholasjackson  路  3Comments

mooneygr picture mooneygr  路  4Comments

satheeshCharles picture satheeshCharles  路  3Comments

lmb picture lmb  路  4Comments

eshujiushiwo picture eshujiushiwo  路  3Comments