查看可以看哪些信息:
http://localhost:8080/actuator
{
“_links”: {
“self”: {
“href”: “http://localhost:8080/actuator”,
“templated”: false
},
“health”: {
“href”: “http://localhost:8080/actuator/health”,
“templated”: false
},
“health-path”: {
“href”: “http://localhost:8080/actuator/health/{*path}”,
“templated”: true
}
}
}
完整的可以参考:
https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints
提供哪些,需要配置:
management:
endpoints:
web:
exposure:
include: info,health,prometheus
配置了include,则需要显式显示配置所有的。例如,之前提到的默认的health也需要配置下,否则访问404
Health check的返回和常见配置:
http://localhost:8080/actuator/health
{“status”:”UP”}
Metrics:
查看可以看哪些:
http://localhost:8080/actuator/metrics/http.server.requests
{
“names”: [
“http.server.requests”,
“jvm.buffer.count”,
“jvm.buffer.memory.used”,
“jvm.buffer.total.capacity”,
“jvm.classes.loaded”,
“jvm.classes.unloaded”,
“jvm.gc.live.data.size”,
“jvm.gc.max.data.size”,
“jvm.gc.memory.allocated”,
“jvm.gc.memory.promoted”,
“jvm.gc.pause”,
“jvm.memory.committed”,
“jvm.memory.max”,
“jvm.memory.used”,
“jvm.threads.daemon”,
“jvm.threads.live”,
“jvm.threads.peak”,
“jvm.threads.states”,
“logback.events”,
“process.cpu.usage”,
“process.start.time”,
“process.uptime”,
“system.cpu.count”,
“system.cpu.usage”,
“tomcat.sessions.active.current”,
“tomcat.sessions.active.max”,
“tomcat.sessions.alive.max”,
“tomcat.sessions.created”,
“tomcat.sessions.expired”,
“tomcat.sessions.rejected”
]
}
具体某项查看:
http://localhost:8080/actuator/metrics/http.server.requests
{
“name”: “http.server.requests”,
“description”: null,
“baseUnit”: “seconds”,
“measurements”: [
{
“statistic”: “COUNT”,
“value”: 84.0
},
{
“statistic”: “TOTAL_TIME”,
“value”: 0.33151280000000005
},
{
“statistic”: “MAX”,
“value”: 0.024693
}
],
“availableTags”: [
{
“tag”: “exception”,
“values”: [
“None”
]
},
{
“tag”: “method”,
“values”: [
“GET”
]
},
{
“tag”: “uri”,
“values”: [
“/actuator/health”,
“/actuator”,
“/actuator/metrics”,
“/**”
]
},
{
“tag”: “outcome”,
“values”: [
“CLIENT_ERROR”,
“SUCCESS”
]
},
{
“tag”: “status”,
“values”: [
“404”,
“200”
]
}
]
}
输出metric:
management.metrics.export.influx.uri=https://influx.example.com:8086
参考https://emacsist.github.io/2018/08/07/springboot%E7%BB%93%E5%90%88influxdb%E6%94%B6%E9%9B%86%E7%9B%91%E6%8E%A7%E7%BB%9F%E8%AE%A1%E4%BF%A1%E6%81%AF/
logger:
http://localhost:8080/actuator/loggers 获取所有log配置
http://localhost:8080/actuator/loggers/{name} 获取某个logger,例如root
发送一个POST请求到http://localhost:8080/actuator/loggers/root,加入如下参数
{
“configuredLevel”: “DEBUG”
}
这个功能对于线上问题的排查非常有用。
一些有用的文档:https://docs.spring.io/spring-boot/docs/2.5.3/actuator-api/pdf/spring-boot-actuator-web-api.pdf