可以通过API接口监控和管理服务的提供者:

1.展示所有的提供者的注册信息:

http://localhost:7001/eureka/apps

返回结果如下

<application>
<name>SPRING-CLOUD-PRODUCTER2-002</name>
<instance>
<instanceId>DESKTOP-PO54VO9:spring-cloud-producter2-002:8002</instanceId>
<hostName>DESKTOP-PO54VO9</hostName>
<app>SPRING-CLOUD-PRODUCTER2-002</app>
<ipAddr>192.168.25.46</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">8002</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1541665321451</registrationTimestamp>
<lastRenewalTimestamp>1541665531526</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1541665321451</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>8002</management.port>
<jmx.port>53608</jmx.port>
</metadata>
<homePageUrl>http://DESKTOP-PO54VO9:8002/</homePageUrl>
<statusPageUrl>http://DESKTOP-PO54VO9:8002/actuator/info</statusPageUrl>
<healthCheckUrl>http://DESKTOP-PO54VO9:8002/actuator/health</healthCheckUrl>
<vipAddress>spring-cloud-producter2-002</vipAddress>
<secureVipAddress>spring-cloud-producter2-002</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1541665321451</lastUpdatedTimestamp>
<lastDirtyTimestamp>1541665321427</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>

2.根据appid获取该实例的基本信息:

http://localhost:7001/eureka/apps/SPRINGCLOUD-EUREKA-CLIENT-008

 

3.设置覆盖状态,暂停应用实例,可以用来做强制实例下线

接口地址:

 http://localhost:7001/eureka/apps/appID/instanceID/status?value=OUT_OF_SERVICE

调用方式:PUT

demo:http://127.0.0.1:7001/eureka/apps/SPRINGCLOUD-EUREKA-CLIENT-008/springcloud-eureka-client-008/status?value=OUT_OF_SERVICE

 

当提供者都 暂停后 此时消费者通过eureka调用提供者时掉不通的

4.删除覆盖状态接口地址: /eureka/apps/appID/instanceID/status?value=UP

调用方式:DELETE

接口说明:删除实例的覆盖状态 , 可以恢复因设置了覆盖状态的实例上线

调用说明:

地址:http://127.0.0.1:7001/eureka/apps/SPRINGCLOUD-EUREKA-CLIENT-008/springcloud-eureka-client-008_2/status?value=UP

 

5.服务下线

接口地址: /eureka/apps/appID/instanceID

调用方式:DELETE

返回状态:HTTPCode: 200 为成功

接口说明:调用该接口,可以直接将服务下线。注意!!!下次心跳又会注册上来。

demo http://127.0.0.1:7001/eureka/apps/SPRINGCLOUD-EUREKA-CLIENT-008/springcloud-eureka-client-008 

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐