Querying a Microservice Instance by Filter Criteria
Function
This API is used to query a microservice instance based on microservice field filter criteria after the instance is registered.
URI
GET /v4/{project_id}/registry/instances
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
appId |
Yes |
String |
Application ID, which must be unique. The value contains 1 to 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 The value contains 1 to 128 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$ |
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 information about the instance. |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-ConsumerId |
No |
String |
Microservice consumer ID, which must be unique. |
Authorization |
No |
String |
This parameter is mandatory if security authentication is enabled for an exclusive microservice engine. Otherwise, this parameter is not required. The token of an exclusive microservice engine with security authentication enabled is in the following format: Authorization:Bearer {Token} For details about how to obtain the token, see Obtaining the User Token of an Exclusive Microservice Engine. |
Response
Status code: 200
Parameter |
Type |
Description |
---|---|---|
instances |
Array of MicroServiceInstance objects |
Instance list. |
Parameter |
Type |
Description |
---|---|---|
instanceId |
String |
Instance ID, which must be unique. The instance ID is generated by the service center. |
serviceId |
String |
Microservice ID, which must be unique. During instance creation, use the microservice ID in the URL instead of the microservice ID specified here. |
version |
String |
Microservice version. |
hostName |
String |
Host information. |
endpoints |
Array of strings |
Access address information. |
status |
String |
Instance status. Value: UP, DOWN, STARTING, or OUTOFSERVICE. Default value: UP. |
properties |
Object |
Extended attribute. You can customize a key and value. The value must be at least 1 byte long. |
healthCheck |
HealthCheck object |
Health check information. |
dataCenterInfo |
DataCenterInfo object |
Data center information. |
timestamp |
String |
Time when an instance is created, which is automatically generated. |
modTimestamp |
String |
Update time. |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Heartbeat mode. Value: push or pull. |
port |
Integer |
Port. |
interval |
Integer |
Heartbeat interval. Unit: s. If the value is less than 5s, the registration is performed at an interval of 5s. |
times |
Integer |
Maximum retries. |
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 message. |
detail |
String |
Location details. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
errorCode |
String |
Error code. |
errorMessage |
String |
Error message. |
detail |
String |
Location details. |
Example Request
Query the instance of the microservice whose application ID is default and microservice name is test.
GET https://{endpoint}/v4/{project_id}/registry/instances?appId=default&serviceName=test
Example Response
Status code: 200
Successfully queried.
{ "instances": [ { "instanceId": "4098483294bb42d8b3c27eee0c166c1c", "serviceId": "8aed80ea052ac04a64dfc79c24f2170224d074f5", "endpoints": [ "rest:127.0.0.1:8080" ], "hostName": "hostNameTest", "status": "UP", "properties": { "engineID": "30c263e5-2eac-4da1-9c72-5abb9ac94550", "engineName": "cse-fkln1-HA" }, "healthCheck": { "mode": "push", "interval": 30, "times": 3 }, "timestamp": "1650545431", "modTimestamp": "1650545442", "version": "1.0.0" } ] }
Status Code
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
500 |
Internal Server Error |
Error Code
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot