Eureka Server REST API
文章目录REST API 介绍REST API 实战查询所有应用实例根据 AppId 查询根据 AppId 及 instanceId 查询根据 instanceId 查询注册新应用实例注销应用实例暂停/下线应用实例恢复应用实例应用实例发送心跳修改应用实例元数据REST API 介绍 Eureka 在 GitHub 的 wiki 上专门写了一篇《 Eureka REST operations》..
·
文章目录
REST API 介绍
Eureka 在 GitHub 的 wiki 上专门写了一篇《 Eureka REST operations》来介绍 Eureka Server 的 REST API 接口,Spring Cloud Netfix Eureka 跟 Spring Boot 适配之后,提供的 REST API 与原始的 REST API 有一点点不同,其路径中的 {version}
值固定为 eureka
,其他的变化不大,如下图所示:
REST API 实战
查询所有应用实例
http://localhost:8761/eureka/apps
根据 AppId 查询
http://localhost:8761/eureka/apps/demo-order
根据 AppId 及 instanceId 查询
http://localhost:8761/eureka/apps/demo-order/guoqingsongmbp:demo-order:11100
根据 instanceId 查询
http://localhost:8761/eureka/instances/guoqingsongmbp:demo-order:11100
注册新应用实例
http://localhost:8761/eureka/apps/demo-order2
请求体参数(XML 格式):
<instance>
<instanceId>demo-order2:11101</instanceId>
<hostName>127.0.0.1</hostName>
<app>DEMO-ORDER2</app>
<ipAddr>127.0.0.1</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">11101</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<metadata class="java.util.Collections$EmptyMap"/>
<vipAddress>demo-order2</vipAddress>
<secureVipAddress>demo-order2</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1540186708769</lastUpdatedTimestamp>
<lastDirtyTimestamp>1540186708747</lastDirtyTimestamp>
</instance>
请求体参数(JSON 格式):
{
"instance": {
"instanceId": "demo-order2:11101",
"app": "demo-order2",
"appGroutName": null,
"ipAddr": "127.0.0.1",
"sid": "na",
"homePageUrl": null,
"statusPageUrl": null,
"healthCheckUrl": null,
"secureHealthCheckUrl": null,
"vipAddress": "demo-order2",
"secureVipAddress": "demo-order2",
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"hostName": "127.0.0.1",
"status": "UP",
"leaseInfo": null,
"isCoordinatingDiscoveryServer": false,
"lastUpdatedTimestamp": 1529391461000,
"lastDirtyTimestamp": 1529391461000,
"actionType": null,
"asgName": null,
"overridden_status": "UNKNOWN",
"port": {
"$": 11102,
"@enabled": "false"
},
"securePort": {
"$": 7002,
"@enabled": "false"
},
"metadata": {
"@class": "java.util.Collections$EmptyMap"
}
}
}
- 查看注册中心结果:
注销应用实例
http://localhost:8761/eureka/apps/demo-order2/demo-order2:11101
暂停/下线应用实例
http://localhost:8761/eureka/apps/demo-order2/demo-order2:11101/status?value=OUT_OF_SERVICE
- 查看注册中心:
恢复应用实例
http://localhost:8761/eureka/apps/demo-order2/demo-order2:11101/status?value=UP
应用实例发送心跳
http://localhost:8761/eureka/apps/demo-order2/demo-order2:11101
修改应用实例元数据
http://localhost:8761/eureka/apps/demo-order2/demo-order2:11101/metadata?profile=canary
- 原元数据:
- 修改后的元数据:
更多推荐
已为社区贡献8条内容
所有评论(0)