Querying Instances of a Microservice Based on the Service ID
Function
This API is used to query all registered instances of a microservice based on the service ID.
URI
GET /v4/{project_id}/registry/microservices/{service_id}/instances
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Unique ID of a tenant sub-project. Length: 1–64 characters. |
| service_id | Yes | String | Microservice ID, which must be unique. Length: 1–64 characters. Regular expression: ^.*$ |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| tags | No | String | Tag. When there are multiple tags, separate them using commas (,). Regular expression: ^[a-zA-Z][a-zA-Z0-9_-.]{0,63}$ |
| env | No | String | Environment of the instance. Value: development, testing, acceptance, or production. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| x-domain-name | Yes | String | Tenant account name. |
| X-consumer_id | Yes | String | Microservice consumer ID, which must be unique. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| instances | Array of MicroServiceInstance objects | Instance list. |
| Parameter | Type | Description |
|---|---|---|
| instanceId | String | Instance ID, which must be unique. During instance creation, instanceId is generated by the service center. |
| serviceId | String | Microservice ID, which must be unique. During instance creation, the service ID in the URL instead of the service ID here is used. |
| version | String | Microservice version. |
| hostName | String | Host information. |
| endpoints | Array of strings | Access address. |
| status | String | Instance status. Value: UP (default), DOWN, STARTING, or OUTOFSERVICE. |
| properties | Object | Extended attribute. You can customize a key and value. The value contains at least 1 byte. |
| healthCheck | HealthCheck object | Health check information. |
| dataCenterInfo | DataCenterInfo object | Data center information. |
| timestamp | String | Instance creation timestamp, which is automatically generated. |
| modTimestamp | String | Update time. |
| Parameter | Type | Description |
|---|---|---|
| mode | String | Heartbeat mode. Value: push or pull. |
| port | Integer | Port. |
| interval | Integer | Interval for sending heartbeat messages, in seconds. |
| times | Integer | Number of failures that are allowed. |
| Parameter | Type | Description |
|---|---|---|
| name | String | Region name. |
| region | String | Region. |
| availableZone | String | AZ. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Example Requests
GET https://{endpoint}/v4/{project_id}/registry/existence Example Responses
Status code: 200
OK
"{\n \"instances\": [\n {\n \"instanceId\": \"string\",\n \"serviceId\": \"string\",\n \"version\": \"string\",\n \"hostName\": \"string\",\n \"endpoints\": [\n \"string\",\n \"string\"\n ],\n \"status\": \"string\",\n \"null\": null,\n \"healthCheck\": {\n \"mode\": \"string\",\n \"port\": 0,\n \"interval\": 0,\n \"times\": 0\n },\n \"dataCenterInfo\": {\n \"name\": \"string\",\n \"region\": \"string\",\n \"availableZone\": \"string\"\n },\n \"timestamp\": \"string\",\n \"modTimestamp\": \"string\"\n }\n ]\n}" Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 500 | Internal Server Error |
Error Codes
See Error Codes.
Last Article: Registering a Microservice Instance
Next Article: Deregistering a Microservice Instance
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.