Querying a Microservice Instance by Filter Criteria
Function
This API is used to query a registered microservice instance based on microservice version rules or field filter criteria.
Constraints
When using special characters such as version 0+, you need to transcode them. For a curl command, you can use quotation marks ('' '') between the content, for example, curl -k "https://{endpoint}/v4/{project_id}/registry/instances?appId=AppTest&serviceName=helloworld&version=0+".
URI
GET /v4/{project_id}/registry/instances
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Unique ID of a tenant sub-project. Length: 1–64 characters. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| appId | Yes | String | Application ID, which must be unique. Length: 1–160 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$ |
| serviceName | Yes | String | Microservice name. Length: 1–128 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$ |
| version | Yes | String | Version rule. Options: 1: exact version matching. For example, 0.0.1. 2: subsequent version matching. For example, 0.0.1+. 3: the latest version. For example, latest. 4: version range. For example, 0.1.0-0.2.0. |
| 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. |
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/instances 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: Sending Heartbeat Messages
Next Article: Querying Microservice Instances in Batches
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.