-
Notifications
You must be signed in to change notification settings - Fork 495
Actuator Endpoint 扩展
Haotian Zhang edited this page Dec 16, 2024
·
10 revisions
服务端点功能自1.6.0
版本开始提供,它基于 spring-boot-actuator
提供的标准接口进行实现,提供 spring-cloud-tencent
开发框架的服务治理相关信息的查询,开发者可以通过引入 spring-boot-starter-actuator
依赖以开启该功能。后面也会持续完善更多的信息提供。
Notice: 由于部分服务治理信息数据比较敏感,因此可以借助
spring-boot-starter-security
提供访问权限控制的功能。
- 添加 actuator 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- 指定要暴露的端点
management:
endpoints:
web:
exposure:
include:
- polarisdiscovery
- polarisconfig
- polarismetadata
- polarisratelimit
- polarisrouter
- Request URL 样例
- Response body 样例
{
"ServiceInstances": [
{
"instances": [
{
"instanceLocalValue": {
"detectResult": null,
"statusDimensions": []
},
"namespace": "default",
"circuitBreakerStatus": null,
"metadata": {
"internal-ip": "127.0.0.1",
"internal-address": "127.0.0.1:8080",
"protocol": "http",
"region": "shanghai"
},
"weight": 100,
"campus": "",
"logicSet": "",
"statusDimensions": [],
"healthy": true,
"revision": "xxx",
"isolated": false,
"enableHealthCheck": true,
"detectResult": null,
"service": "DiscoveryCallerService",
"priority": 0,
"id": "xxx",
"protocol": "http",
"host": "127.0.0.1",
"port": 8080,
"region": "shanghai",
"version": "",
"zone": ""
}
],
"totalWeight": 100,
"allInstances": [
{
"instanceLocalValue": {
"detectResult": null,
"statusDimensions": []
},
"namespace": "default",
"circuitBreakerStatus": null,
"metadata": {
"internal-ip": "127.0.0.1",
"internal-address": "127.0.0.1:8080",
"protocol": "http",
"region": "shanghai"
},
"weight": 100,
"campus": "",
"logicSet": "",
"statusDimensions": [],
"healthy": true,
"revision": "xxx",
"isolated": false,
"enableHealthCheck": true,
"detectResult": null,
"service": "DiscoveryCallerService",
"priority": 0,
"id": "xxx",
"protocol": "http",
"host": "127.0.0.1",
"port": 8080,
"region": "shanghai",
"version": "",
"zone": ""
}
],
"namespace": "default",
"metadata": {
"internal-auto-created": "true"
},
"serviceKey": {
"namespace": "default",
"service": "DiscoveryCallerService"
},
"initialized": true,
"revision": "xxx",
"service": "DiscoveryCallerService"
}
],
"PolarisDiscoveryProperties": {
"namespace": "default",
"service": "DiscoveryCallerService",
"token": null,
"weight": 100,
"version": null,
"protocol": "http",
"port": 8080,
"enabled": true,
"registerEnabled": true,
"heartbeatEnabled": true,
"healthCheckUrl": "/discovery/service/caller/healthCheck",
"serviceListRefreshInterval": 60000
}
}
- Request URL 样例
- Response body 样例
{
"PolarisPropertySource": [
{
"name": "default-polaris-config-example-config/application.properties",
"source": {},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "config/application.properties",
"propertySourceName": "default-polaris-config-example-config/application.properties",
"propertyNames": []
},
{
"name": "default-polaris-config-example-config/bootstrap.yml",
"source": {},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "config/bootstrap.yml",
"propertySourceName": "default-polaris-config-example-config/bootstrap.yml",
"propertyNames": []
},
{
"name": "default-polaris-config-example-bootstrap.properties",
"source": {},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "bootstrap.properties",
"propertySourceName": "default-polaris-config-example-bootstrap.properties",
"propertyNames": []
},
{
"name": "default-polaris-config-example-bootstrap.yml",
"source": {},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "bootstrap.yml",
"propertySourceName": "default-polaris-config-example-bootstrap.yml",
"propertyNames": []
},
{
"name": "default-polaris-config-example-application.yml",
"source": {
"teacher.age": "19",
"teacher.name": "张三"
},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "application.yml",
"propertySourceName": "default-polaris-config-example-application.yml",
"propertyNames": [
"teacher.age",
"teacher.name"
]
},
{
"name": "default-polaris-config-example-application.properties",
"source": {},
"namespace": "default",
"group": "polaris-config-example",
"fileName": "application.properties",
"propertySourceName": "default-polaris-config-example-application.properties",
"propertyNames": []
}
],
"PolarisConfigProperties": {
"enabled": true,
"address": null,
"port": 8093,
"autoRefresh": true,
"groups": [
{
"name": "polaris-config-example",
"files": [
"config/application.properties",
"config/bootstrap.yml"
]
}
]
}
}
- Request URL 样例
- Response body 样例
{
"zone": null,
"Config": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE",
"CUSTOM-METADATA-KEY-LOCAL": "CUSTOM-VALUE-LOCAL"
},
"campus": null,
"ConfigTransitive": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
},
"MergeStatic": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE",
"CUSTOM-METADATA-KEY-LOCAL": "CUSTOM-VALUE-LOCAL"
},
"CustomSPI": {},
"Env": {},
"region": null,
"EnvTransitive": {}
}
- Request URL 样例
- Response body 样例
{
"rateLimitRules":[
{
"amounts":"[{maxAmount=4, validDuration=1s}]",
"service":"RateLimitCalleeService",
"disable":"false",
"namespace":"default",
"action":"UNIRATE",
"ctime":"2022-06-14 14:32:57",
"id":"947ba6c1cc6b43e0a35335ada3cf360c",
"priority":"0",
"type":"LOCAL",
"mtime":"2022-07-14 15:42:17",
"labels":"{*={type=REGEX, value=*}, method={type=REGEX, value=/business/info/*}}",
"revision":"879b902e2144455aa5e11575cbda2883"
}
],
"service":"RateLimitCalleeService",
"namespace":"default",
"properties":{
"rejectRequestTips":null,
"rejectRequestTipsFilePath":"reject-tips.html",
"rejectHttpCode":429,
"maxQueuingTime":500
}
}
- Request URL 样例
{
"routerRules":[
{
"sources":[
{
"metadata":"{${http.header.uid}={value=1000}}",
"service":"*",
"namespace":"*"
}
],
"destinations":[
{
"isolate":"false",
"metadata":"{label={value=value1}}",
"service":"RouterCalleeService",
"namespace":"default",
"weight":"100",
"priority":"0"
},
{
"isolate":"true",
"metadata":"{dd={value=ddd}}",
"service":"RouterCalleeService",
"namespace":"default",
"weight":"100",
"priority":"0"
}
]
},
{
"sources":[
{
"metadata":"{*={value=*}}",
"service":"*",
"namespace":"*"
}
],
"destinations":[
{
"isolate":"false",
"metadata":"{q={value=q}}",
"service":"RouterCalleeService",
"namespace":"default",
"weight":"100",
"priority":"0"
}
]
}
]
}
- Request URL 样例
http://127.0.0.1:8080/actuator/polariscircuitbreaker/${被调端服务名}
{
"circuitBreakerRules": [
{
"errorConditions": "[{inputType=RET_CODE, condition={value=502}}]",
"ruleMatcher": "{source={service=QuickstartCallerService, namespace=default}, destination={service=QuickstartCalleeService, namespace=default}}",
"triggerCondition": "[{triggerType=ERROR_RATE, errorCount=10, errorPercent=50, interval=5, minimumRequest=1}]",
"level": "SERVICE",
"fallbackConfig": "{enable=true, response={code=203, headers=[{key=name, value=skye}], body=熔断了}}",
"mtime": "2023-12-26 16:17:54",
"revision": "ad720faf304849b1ab8d27a11b2105dc",
"faultDetectConfig": "{}",
"recoverCondition": "{sleepWindow=60, consecutiveSuccess=3}",
"enable": "true",
"name": "quickstart-caller",
"namespace": "default",
"ctime": "2023-12-26 16:17:54",
"id": "161dcae0c53f48be9832231ae3e022d4"
}
],
"service": "QuickstartCallerService",
"namespace": "default"
}
- 您在使用过程中遇到任何问题,请提 Issue 或者加入我们的开发者群告诉我们,我们会在第一时间反馈
- Spring Cloud Tencent 社区期待您的加入,一个 Star、PR 都是对我们最大的支持
- 项目介绍
- 使用指南
- 最佳实践
- 开发文档
- 学习资料