概念:

通过引入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();
}
}

Spring Boot与监控管理的更多相关文章

  1. spring Boot(十九):使用Spring Boot Actuator监控应用

    spring Boot(十九):使用Spring Boot Actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台 ...

  2. (39.4) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    在读此文章之前您还可能需要先了解: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...

  3. (39.3) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    在学习此小节之前您可能还需要学习: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...

  4. (39.2). Spring Boot Shiro权限管理【从零开始学Spring Boot】

    (本节提供源代码,在最下面可以下载) (4). 集成Shiro 进行用户授权 在看此小节前,您可能需要先看: http://412887952-qq-com.iteye.com/blog/229973 ...

  5. (39.1) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    (本节提供源代码,在最下面可以下载)距上一个章节过了二个星期了,最近时间也是比较紧,一直没有时间可以写博客,今天难得有点时间,就说说Spring Boot如何集成Shiro吧.这个章节会比较复杂,牵涉 ...

  6. Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用

    Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用 1. 引言 在上一篇文章<Spring Boot (九): 微服务应用监控 Spring ...

  7. Spring Boot Actuator监控使用详解

    在企业级应用中,学习了如何进行SpringBoot应用的功能开发,以及如何写单元测试.集成测试等还是不够的.在实际的软件开发中还需要:应用程序的监控和管理.SpringBoot的Actuator模块实 ...

  8. Springboot 系列(十七)迅速使用 Spring Boot Admin 监控你的 Spring Boot 程序,支持异常邮件通知

    1. Spring Boot Admin 是什么 Spring Boot Admin 是由 codecentric 组织开发的开源项目,使用 Spring Boot Admin 可以管理和监控你的 S ...

  9. 使用 Spring Boot Admin 监控应用状态

    程序员优雅哥 SpringBoot 2.7 实战基础 - 11 - 使用 Spring Boot Admin 监控应用状态 1 Spring Boot Actuator Spring Boot Act ...

随机推荐

  1. PAT_A1020#Tree Traversals

    Source: PAT A1020 Tree Traversals (25 分) Description: Suppose that all the keys in a binary tree are ...

  2. Python3 From Zero——{最初的意识:005~文件和I/O}

    一.输出重定向到文件 >>> with open('/home/f/py_script/passwd', 'rt+') as f1: ... print('Hello Dog!', ...

  3. sql实现取汉字大写首字母

    )) ) AS BEGIN DECLARE @py TABLE( ch ), hz1 ) COLLATE Chinese_PRC_CS_AS_KS_WS, hz2 ) COLLATE Chinese_ ...

  4. 小明系列故事――女友的考验 HDU - 4511 AC自动机+简单DP

    题意:自己看题目,中文体面. 题解: 把所有不能走的路径放入AC自动机中. 然后DP[i][j]表示走到 i 这个点,且位于AC自动机 j 这个节点最短距离 然后直接DP即可.注意一点会爆int #i ...

  5. 解决通过vmware克隆虚拟机后,无法上网的问题

    注意:如果源主机是CentOS 6.8,复制出来的机器会出现无法上网. 如果源主机是CentOS 7,复制出来的机器可以正常上网.复制后,只要改下IP地址即可上网. 出现该问题的原因是,我们克隆后,将 ...

  6. D3.js比例尺 序数比例尺(v3版本)

    上一章介绍了阈值比例尺:https://www.cnblogs.com/littleSpill/p/10825038.html.到目前所有的定量比例尺已经介绍完了. 现在给大家介绍一下序数比例尺. 定 ...

  7. [JZOJ1901] 【2010集训队出题】光棱坦克

    题目 题目大意 给你个平面上的一堆点,问序列\({p_i}\)的个数. 满足\(y_{p_{i-1}}>y_{p_i}\)并且\(x_{p_i}\)在\(x_{p_i-1}\)和\(x_{p_i ...

  8. curl 基础

    简介 curl 是常用的命令行工具,用来请求 Web 服务器.它的名字就是客户端(client)的 URL 工具的意思. 它的功能非常强大,命令行参数多达几十种.如果熟练的话,完全可以取代 Postm ...

  9. kafka-node+socket.io 测试配置

    1.安装需要插件 npm install express npm install  socket.io npm install  kafka-node 2.kafkatest.js文件 var exp ...

  10. python定时任务模块APScheduler

    一.简单任务 定义一个函数,然后定义一个scheduler类型,添加一个job,然后执行,就可以了 5秒整倍数,就执行这个函数 # coding:utf-8 from apscheduler.sche ...