Register multiple services with different service endpoints but same port?

We are planning to host a bunch of Prometheus metrics(with different endpoints) with the same port, the metric server endpoints will be like:

  1. http://localhost:9090/ServiceCategory1/SubService01/
  2. http://localhost:9090/ServiceCategory1/SubService02/
  3. http://localhost:9090/ServiceCategory2/SubService01/
  4. http://localhost:9090/ServiceCategory2/SubService02/

My current API registration payload will ignore the port but put the whole metric service endpoint to Address field like the following

{
  "ID": "ServiceId0001",
  "Name": "ServiceName",
  "Tags": [
    "primary",
    "v1"
  ],
  "Address": "http://localhost:9090/ServiceCategory1/SubService01",
  "Meta": {
    "service_version": "4.0"
  },
  "Check": {
    "name": "Ping check",
    "DeregisterCriticalServiceAfter": "1m",
    "Interval": "10s",
    "Timeout": "5s",
    "HTTP": "http://localhost:9090/ServiceCategory1/SubService01"
  }
}

The address shown in Consul will be like:

http://localhost:9090/ServiceCategory1/SubService01/:0

it’s not quite right but can be working with Prometheus by re-labeling tweak, however, the HTTP check didn’t work of course

Not sure if anyone here can show me the correct way to achieve this or this is not achievable?

All right, found the reason why the HTTP check didn’t work at the first place, because the dev environment had a forced proxy configuration and an enterprise firewall which block all local server request… :joy:

Switch to an environment without Proxy, HTTP check works as expected. :white_check_mark:

1 Like

Thanks for the update @zscn, that would have been tough to find out!