概念:

通过引入spring-boot-starter-actuator,可以使用Spring Boot为我们提供的准生产环境下的应用监控和管理功能。我们可以通过HTTP,JMX,SSH协议来进行操作,自动得到审计、健康及指标信息等。

步骤:

  1. 引入spring-boot-starter-actuator
  2. 通过http方式访问监控端点
  3. 可进行shutdown(POST 提交,此端点默认关闭)

监控和管理端点中文对照

常用定制端点信息方法:

1.定制端点一般通过endpoints+端点名+属性名来设置。

2.修改端点id(endpoints.beans.id=mybeans)

3.开启远程应用关闭功能(endpoints.shutdown.enabled=true)

4.关闭端点(endpoints.beans.enabled=false)

5.开启所需端点

endpoints.enabled=false endpoints.beans.enabled=true

6.定制端点访问根路径

management.context-path=/manage

7.关闭http端点

management.port=-1

springboot版本:1.5.12

http://localhost:8080/info 可以查看git的配置信息

git.properties:

git.branch=master
git.commit.id=xjkd33s
git.commit.time=2017-12-12 12:12:56

http://localhost:8080/XXXX

application.properties:

#设置监控端点可见
management.security.enabled=false #测试redis的health
spring.redis.host=192.168.0.113 #设置localhost:8080/info的值
info.app.id=hello
info.app.version=1.0.0 #设置metrics端点不可见
#endpoints.metrics.enabled=false
endpoints.shutdown.enabled=true #设置beans的名字,改后访问路径为:localhost:8080/mybean
#endpoints.beans.id=mybean
#设置beans的访问路径,改后访问路径为:localhost:8080/bean
#endpoints.beans.path=/bean
#endpoints.beans.enabled=false
#
#endpoints.dump.path=/du # 关闭所有端点访问
#endpoints.enabled=false
# 打开beans端点的访问
#endpoints.beans.enabled=true #设置访问端点前缀
management.context-path=/manage
#设置访问端口号
management.port=8181

自定义HealthIndicator:

/*
* 自定义健康状态指示器
* 1.编写一个指示器 实现healthIndicator 接口
* 2.指示器名字 xxxxHealthIndicator
* 3.加入容器中
* */ @Component
public class MyAppHealthIndicator implements HealthIndicator {
@Override
public Health health() { //自定义的检查方法
//return Health.up().build();//代表健康
return Health.down().withDetail("msg","服务异常").build();
}
}

最新文章

  1. centos 7 安装音乐播放器(亲测可用)(转载)
  2. SVN-Server搭建及配置
  3. JAVA Socket 编程学习笔记(二)
  4. 自动完成--autoComplete插件
  5. Jenkins pipeline 入门到精通系列文章
  6. PacBio长reads的大基因组组装
  7. selenium执行js报错
  8. [SQL]开启事物,当两条插入语句有出现错误的时候,没有错误的就插入到表中,错误的语句不影响到正确的插入语句
  9. IOC框架的认识
  10. input 表单点击消失离开出现
  11. 一条sql语句循环插入N条不同记录(转)
  12. phing用户手册第四章Getting Started译文
  13. POJ 3013 Big Christmas Tree(最短Dijkstra+优先级队列优化,SPFA)
  14. ReactiveX--响应式编程の相关概念 浅析
  15. Linux 系统根目录下各个文件夹的作用
  16. 论文笔记 SSD: Single Shot MultiBox Detector
  17. rayleighchan实现瑞利多径衰落信
  18. 使用VMware将Linux装在物理硬盘上,开机即可进入Linux (转)
  19. buff/cache 内容释放
  20. IE访问历史记录恢复工具pasco

热门文章

  1. (二十三)Http请求的处理过程
  2. 应用Dubbo框架打造仿猫眼项目 理解微服务核心思想
  3. javascript面向对象编程笔记(函数)
  4. winsock 服务器代码(不建议win服务器listen防火墙会禁止外部访问的)
  5. 【笔记篇】单调队列优化dp学习笔记&&luogu2569_bzoj1855股票交♂易
  6. CSIC_716_20191107【深拷贝、文件的编码解码、文件的打开模式】
  7. sql语句之条件,分页,排序
  8. curl 基础
  9. CSS3——动画
  10. Perl 数组