Register multiple external services to same node

Hi, I’m using ESM to monitor external services from Consul. I was wondering whether I can assign multiple services to the same node. Basically the same approach as it’s done for Checks: you can specify to register one check or multiple checks. As described here https://www.consul.io/api/catalog.html#register-entity

I would like to do the same for services.
Many thanks!

Hi @Vinclame! Thanks for your question! To make sure I understand your question, it sounds like the checks feature you’re referring to in Catalog Register is specifically:

Multiple checks can be provided by replacing Check with Checks and sending an array of Check objects.

Basically you’d like to similarly use a single API request to register multiple services. Please correct if I misunderstood.

If that’s correct, unfortunately there is not an equivalent in Catalog Register to register multiple services at a time. The Service parameter takes only a single service and there is no Services option. Using Catalog Register, you’d have to make multiple API requests, one for each service.

One alternative that you can use is the Transaction API which would allow you to register multiple services with one API request. For example:

curl -X PUT --data @txn.json http://localhost:8500/v1/txn

txn.json:

[
   {
       "Node": {
           "Verb": "set",
           "Node": {
               "Node": "node_a",
               "Address": "127.0.0.1",
               "Meta": {
                   "external-node": "true",
                   "external-probe": "false"
               }
           }
       }
   },
   {
       "Service": {
           "Verb": "set",
           "Node": "node_a",
           "Service": {
               "Service": "web",
               "ID": "web"
           }
       }
   },
   {
       "Service": {
           "Verb": "set",
           "Node": "node_a",
           "Service": {
               "Service": "api",
               "ID": "api"
           }
       }
   }
]

Hope that’s helpful! Let us know any follow up questions. Thank you.

Hi @lornasong,

thanks for your answer. Thats indeed what I wanted to know. I already register each service via a separate API call (as you described). Good to know that I can use the Transaction API as well. Thanks!