全栈之路微服务课程三监控Spring-Boot-Actuator

3次阅读

共计 708 个字符,预计需要花费 2 分钟才能阅读完成。

前言

现阶段是 Growth Hack 逐渐成为主流的时代,系统压力、QPS、CPU、内存、日活等可视化 Dashboard 已成为系统重要的一份子。

pom.xml 依赖引入

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.yml 配置

management:
  endpoints:
    web:
      exposure:
        # 开放所有监控端点
        include: '*'
  endpoint:
    health:
      # 是否展示健康检查详情
      show-details: always

断点监控

ator 为我们提供了很多监控端点,如下表所示。


访问 http://{ip}:{port}/actuator/{endpoint} 端点,即可监控应用的运行状况。

测试

http://localhost:8000/actuator/health

{
    "status": "UP",
    "details": {
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 107374178304,
                "free": 15758929920,
                "threshold": 10485760
            }
        },
        "db": {
            "status": "UP",
            "details": {
                "database": "MySQL",
                "hello": 1
            }
        },
        "refreshScope": {"status": "UP"}
    }
}

注意事项

如需可视化界面,可参考:https://github.com/codecentri…

正文完
 0