springboot使用actuator
序
最近有点空闲,回头来处理一些没有的注释,然后,是不是换换脑子,给springboot加点东西。几天来说说开启监控acuator的问题。不废话,看招。
一、maven引入jar
<!-- actuator支持 -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
这里之前引入过spring-boot-starter-web,所以就不重复写了
二、actuator配置
#actuator配置
#管理端口,不设置默认与server的端口一致
#management.port=54001
#jmx排除监控点
#management.endpoints.jmx.exposure.exclude=*
#jmx包含监控点
management.endpoints.jmx.exposure.include=*
#使用web端测试,配置监控点,exclude排除,include包含,配置*所有的意思,可单独配置health、info
#management.endpoints.web.exposure.exclude=*
management.endpoints.web.exposure.include=*
#actuator开关配置
#management.health.db.enabled=true
#management.health.mail.enabled=true
#management.health.security.enabled=true
三、可能回遇到的异常
No converter for [class org.springframework.boot.actuate.health.SystemHealth] with preset Content-Type ‘null’
这个意思就是缺少转换器,我这里的WebMvcConfigurer是实现的WebMvcConfigurationSupport。有博友说实现这个确实会有一些问题。我这里就是出现了这个问题,首先我是怀疑静态资源不能被访问导致,后来在addInterceptors里各种加,就是无效。后来想想,这前后端分离的,我这里就没有静态资源。然后想都我这里是用的fastjson做的HttpMessageConverter,有可能就是这里的问题。
/*** 使用阿里 FastJson 作为JSON MessageConverter*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();FastJsonConfig config = new FastJsonConfig();config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.PrettyFormat,SerializerFeature.WriteNullStringAsEmpty,SerializerFeature.WriteNullListAsEmpty);converter.setFastJsonConfig(config);converter.setDefaultCharset(Charset.forName("UTF-8"));converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));converters.add(0, converter);//super.addDefaultHttpMessageConverters(converters);
}
原始我就是这样的,可能大家已经看到问题了。super.addDefaultHttpMessageConverters(converters);注释掉的,都没有把fastjson加到默认HttpMessageConverters里。
于是放开这一行,重新请求:http://localhost:8099/actuator/health,结果:
四、返回自定义结果
那就需要自己实现HealthIndicator 、InfoIndicator等相关监测器。
剩下的大家就自己发挥吧,是单独搭建一个服务定时请求、还是其他方式,都是ok的。
springboot使用actuator相关推荐
- SpringBoot集成Actuator端点配置
1.说明 Actuator端点可以监控应用程序并与之交互. Spring Boot包括许多内置的端点, 比如health端点提供基本的应用程序运行状况信息, 并允许添加自定义端点. 可以控制每个单独的 ...
- SpringBoot集成Actuator监控管理
1.说明 本文详细介绍Spring Boot集成Actuator监控管理的方法, 基于已经创建好的Spring Boot工程, 然后引入Actuator依赖, 介绍监控管理相关功能的使用. Sprin ...
- springboot集成Actuator
Actuator监控端点,主要用来监控与管理. 原生端点主要分为三大类:应用配置类.度量指标类.操作控制类. 应用配置类:获取应用程序中加载的配置.环境变量.自动化配置报告等与SpringBoot应用 ...
- springboot整合Actuator监控
springboot整合Actuator监控. 1.简要说明: Actuator提供了对springboot应用程序监视和管理的能力,可以选择通过使用HTTP Endpoint或者使用JMX来管理和监 ...
- SpringBoot监控Actuator,关闭redis监测
SpringBoot监控Actuator,关闭redis监测 方法 方法 当我们导入了spring-boot-starter-actuator这个依赖后, SpringBoot会默认去监测一些信息.其 ...
- SpringBoot:Actuator 监控管理工程各项信息
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 在微服务体系中,有很多工程相互作用,如果其中某一个Down 了,可能就不是那么容易快速定位 bug ...
- Springboot之actuator配置不当漏洞(autoconfig、configprops、beans、dump、env、health、info、mappings、metrics、trace)
前言 Actuator 是 springboot 提供的用来对应用系统进行自省和监控的功能模块,借助于 Actuator 开发者可以很方便地对应用系统某些监控指标进行查看.统计等.在 Actuator ...
- SpringBoot集成Actuator健康指示器health
1.说明 本文详细介绍Actuator提供的HealthIndicators, 即健康指示器的配置使用, 利用自动配置的健康指标, 检查正在运行的应用程序的状态, 以及自定义健康指标的方法. 监控软件 ...
- springboot 集成 actuator
简介 spring-actuator做度量统计收集,使用Prometheus(普罗米修斯)进行数据收集,Grafana(增强ui)进行数据展示,用于监控生成环境机器的性能指标和业务数据指标.一般,我们 ...
- Springboot使用Actuator健康监控以及可视化界面
前言 我们的微服务在云上部署以后都需要对其进行监控.追踪.审计.控制等.SpringBoot就抽取了Actuator场景,使得我们每个微服务快速引用即可获得生产级别的应用监控.审计等功能. DEMO ...
最新文章
- CloudCompare的介绍
- 各种抠图动态图片_学习抠取动物毛发图片的PS抠图技巧
- iOS 发大招 otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法 编写通用类的时候关于可变参数的处理...
- 2021-03-02 英文写作中的“但是”
- 协议crc计算_从零了解modbus协议 第三篇
- 数据仓库设计方案(转载)
- jquery报.live() is not a function的解决方法
- 论文笔记_S2D.54_2020-TIP_用于精确深度估计的无监督多视图约束卷积网络
- AutoCAD中的Spline曲线算法分析(二)
- 移动硬盘损坏:文件或目录已损坏(修复实录)
- day16正则表达式作业
- kali安装软件源软件
- html是什么意思 它是一种什么样的语言,HTML 是什么?
- css小tips -- figcaption标签
- 场景识别帮助小白用户实现一键式智能拍照修图
- 关于Intellij idea里在pom.xml里添加Maven依赖,本地仓库下拉列表显示包很少的血的经验
- Adversarial Learning
- 机器学习1-线性模型及多分类
- 帝国ECMS教程:上一篇下一篇自定义综合代码
- 微软的黑屏说明了什么?