服务监测相关:
监测:监测方与被监测方通信,收集被监测方存活及指标等相关信息,给予显示和报警。
以服务存活为例:监测方每隔一段时间询问被监测方“是否存活”,被监测方回答“是”则仍为被监测方存活。
监测需要:
被监测方:提供接口来响应检测方
检测方:1.向被监测方发送请求 2.处理被监测方返回的信息
由于各种服务增多,程序员肯定懒得写,于是就有了监测相关的框架。
what:
- spring boot子项目
- 提供了很多生产级的特性
- 通过http端口或JMX来监测和管理服务的功能。
how:
- actuator使用端点(endpoints)来监测应用/和应用交互。
- 各个端点彼此独立,都可以根据需要开关(enabled/disabled)。
yml/properties中配置
- actuator内置了大量端点供用户使用。
如:health/metrics/loggers/shutdown。。。
web端还包括:logfile/heapdump/prometheus/jolokia
内置端点可对外暴露HTTP接口。通过/prefix(default actuator)/endpoint-id
ps:
1. prefix可以修改,但不建议直接/,不然配置拦截器和过滤器神烦。
2. 内置端点logfile通过在yml/properties中配置logging.file&logging.path属性,可以通过接口读取日志文件内容。
并不能读取appender。如需要读取appender,可以采取自定义实现。
- endpoint可以自定义
- 内置endpoint
- 如果不希望接口对外暴露可以配合springboot security一起食用风味更加。本篇暂略下不表。
参考:
官方文档: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready
quick-start&内置端口详解: http://www.ityouknow.com/springboot/2018/02/06/spring-boot-actuator.html
看起来比官方文档舒服的网站:https://www.baeldung.com/spring-boot-actuators
### springboot admin:
https://github.com/codecentric/spring-boot-admin
http://codecentric.github.io/spring-boot-admin/2.0.2/