spring boot监控之actuator--持续更新

 

一、环境配置

1、pom文件配置

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/>
</parent>
<!-- 运行状态监控actuator -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2、yml文件配置

spring boot 2.0配置方法已更新,具体配置可查看spring boot官网Endpoints配置,如下为开启所有监控端点的写法:

management:
  server:
    port: 9002
  endpoints:
    web:
      exposure:
        include: '*'

启动spring boot应用,看到如下信息,表示actuator启动并配置成功,具体某个端点的作用可在Endpoints配置中查看:

在spring boot 2.0中,默认情况下,访问http://localhost:9002/stag/actuator/health端点只会提供简单的状态信息:

{"status":"UP"}

如需查看更多的详细信息,需要在yml中添加额外配置:

#----------actuator--------
management:
  server:
    port: 9002
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: always

修改配置后访问http://localhost:9002/stag/actuator/health显示如下信息,更多讲解可查看spring boot 2.0 actuator 健康检查: 

{
	"status": "UP",
	"details": {
		"diskSpace": {
			"status": "UP",
			"details": {
				"total": 1000201674752,
				"free": 647068315648,
				"threshold": 10485760
			}
		},
		"db": {
			"status": "UP",
			"details": {
				"dataSource": {
					"status": "UP",
					"details": {
						"database": "MySQL",
						"hello": 1
					}
				},
				"dev-dataSource": {
					"status": "UP",
					"details": {
						"database": "MySQL",
						"hello": 1
					}
				}
			}
		},
		"redis": {
			"status": "UP",
			"details": {
				"version": "3.2.100"
			}
		}
	}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值