Service Discovery

Hi all,

I am trying to register onprem multiple nodes in consul DB using single json file but while registering through API, getting syntax error (Request decode failed: json: cannot unmarshal array into Go value of type structs.RegisterRequest)

I am using below curl command for registering the nodes
curl --request PUT --data @nodes.json http://x.x.x.x:8500/v1/catalog/register

Below is the node json file I am using:

[
{
“Node”: “ABC”,
“Address”: “ABC.net”,
“NodeMeta”: {
“external-node”: “true”,
“external-probe”: “true”
},
“Service”: {
“ID”: “node_exporter”,
“Service”: “monitoring”,
“Tags”: [“node_exporter”],
“Port”: 9100
}
},
{
“Node”: “XYZ”,
“Address”: “XYZ.net”,
“NodeMeta”: {
“external-node”: “true”,
“external-probe”: “true”
},
“Service”: {
“ID”: “node_exporter”,
“Service”: “monitoring”,
“Tags”: [“node_exporter”],
“Port”: 9100
}
}
]

I am not installing consul agent in those nodes, just trying to register those external nodes in consul DB and from their Prometheus has to discover those nodes.

Can anyone please suggest on adding multiple nodes with one json file.

Thanks

Consul does not support registering multiple service instances via a single API call. You will need to make separate API calls in order to register these entities in the catalog.