Actuator监控:SpringBoot自带的,对生成环境进行监控的系统

使用:既然是监控,那就不能监控一个空项目

这里我使用SpringBoot整合MyBatis的Demo:

https://www.cnblogs.com/xuyiqing/p/10837299.html

依赖

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

然后直接启动项目即可

访问http://localhost:8080/actuator

{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health-component-instance": {
"href": "http://localhost:8080/actuator/health/{component}/{instance}",
"templated": true
},
"health-component": {
"href": "http://localhost:8080/actuator/health/{component}",
"templated": true
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
"info": {
"href": "http://localhost:8080/actuator/info",
"templated": false
}
}
}

显示可监控列表

访问http://localhost:8080/actuator/health

{"status":"UP"}

说明状态正常

进一步地,使用Actuator获取地JSON可以写前端页面进行显示,或者结合定时任务

比如定时访问http://localhost:8080/actuator/health,如果返回UP说明正常,然后进行其他操作

问题解决:访问http://localhost:8080/actuator/health显示404

原因:SpringBoot版本问题,SpringBoot1.x访问http://localhost:8080/health

其实这里获得的是较少的信息,更多的信息需要进行配置:

management.endpoints.web.exposure.include=*

现在访问:http://localhost:8080/actuator

{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"auditevents": {
"href": "http://localhost:8080/actuator/auditevents",
"templated": false
},
"beans": {
"href": "http://localhost:8080/actuator/beans",
"templated": false
},
"caches-cache": {
"href": "http://localhost:8080/actuator/caches/{cache}",
"templated": true
},
"caches": {
"href": "http://localhost:8080/actuator/caches",
"templated": false
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
"health-component-instance": {
"href": "http://localhost:8080/actuator/health/{component}/{instance}",
"templated": true
},
"health-component": {
"href": "http://localhost:8080/actuator/health/{component}",
"templated": true
},
"conditions": {
"href": "http://localhost:8080/actuator/conditions",
"templated": false
},
"configprops": {
"href": "http://localhost:8080/actuator/configprops",
"templated": false
},
"env": {
"href": "http://localhost:8080/actuator/env",
"templated": false
},
"env-toMatch": {
"href": "http://localhost:8080/actuator/env/{toMatch}",
"templated": true
},
"info": {
"href": "http://localhost:8080/actuator/info",
"templated": false
},
"loggers": {
"href": "http://localhost:8080/actuator/loggers",
"templated": false
},
"loggers-name": {
"href": "http://localhost:8080/actuator/loggers/{name}",
"templated": true
},
"heapdump": {
"href": "http://localhost:8080/actuator/heapdump",
"templated": false
},
"threaddump": {
"href": "http://localhost:8080/actuator/threaddump",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://localhost:8080/actuator/metrics/{requiredMetricName}",
"templated": true
},
"metrics": {
"href": "http://localhost:8080/actuator/metrics",
"templated": false
},
"scheduledtasks": {
"href": "http://localhost:8080/actuator/scheduledtasks",
"templated": false
},
"httptrace": {
"href": "http://localhost:8080/actuator/httptrace",
"templated": false
},
"mappings": {
"href": "http://localhost:8080/actuator/mappings",
"templated": false
}
}
}

访问:http://localhost:8080/actuator/env

获得配置信息

访问:http://localhost:8080/actuator/beans

监控项目Spring中的beans

访问:http://localhost:8080/actuator/metrics

查看应用基本指标列表

通常不建议全部开启,因为不安全

所以,可以这样配置

#开启全部
management.endpoints.web.exposure.include=*
#开启某个
management.endpoints.web.exposure.include=metrics
#关闭某个
management.endpoints.web.exposure.exclude=metrics

SpringBoot的学习暂时结束了:

总结和未来规划:

学会了基本的配置、整合Mybatis、Redis、ActiveMQ、ElasticSearch等

技术栈的规划:

初级路线:Java基础->Java Web(html+css+js,servlet,request+response,ajax,mysql+jdbc...)->SSM、SSH->SpringBoot->Spring Cloud

高级路线:Linux->源码阅读(Spring、JDK)->数据库优化(分库分表,慢查询,调优...)->缓存(Redis集群...)->HTTP/HTTPS协议优化

                 ->安全(XSS、DDOS、CSRF)->消息队列(ActiveMQ,Kafka,RocketMQ)->搜索框架(Lucene、Solr、ElasticSearch)->Docker、K8S

下面开始Spring Cloud的学习!

SpringBoot 2.x (15):Actuator监控的更多相关文章

  1. springboot(十九)使用actuator监控应用【转】【补】

    springboot(十九)使用actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的 ...

  2. SpringBoot要点之使用Actuator监控

    Actuator是Springboot提供的用来对应用系统进行自省和监控的功能模块,借助于Actuator开发者可以很方便地对应用系统某些监控指标进行查看.统计等. 在pom文件中加入spring-b ...

  3. springboot(十九)使用actuator监控应用

    微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...

  4. SpringBoot Actuator监控【转】

    springboot actuator 监控 springboot1.5和springboot2.0 的actuator在启动日志上的差异就很大了. springboot1.5在启动时会打印很多/XX ...

  5. SpringBoot入门教程(十)应用监控Actuator

    Actuator可能大家非常熟悉,它是springboot提供对应用自身监控,以及对应用系统配置查看等功能.spring-boot-starter-actuator模块的实现对于实施微服务的中小团队来 ...

  6. SpringBoot系列: Actuator监控

    Sprng Boot 2 actuator变动加大, 网上很多资料都都已经过期. ============================配置项============================ ...

  7. SpringBoot系列九:SpringBoot服务整合(整合邮件服务、定时调度、Actuator监控)

    声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅. 1.概念:SpringBoot 服务整合 2.背景 在进行项目开发的时候经常会遇见以下的几个问题:需要进行邮件发送.定时的任务调 ...

  8. SpringBoot集成Actuator监控管理

    1.说明 本文详细介绍Spring Boot集成Actuator监控管理的方法, 基于已经创建好的Spring Boot工程, 然后引入Actuator依赖, 介绍监控管理相关功能的使用. Sprin ...

  9. springboot(十九):使用Spring Boot Actuator监控应用

    微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...

随机推荐

  1. C++之MutexLock和MutexLockGuard封装

    noncopyable.h #ifndef __WD_NONCOPYABLE_H__ #define __WD_NONCOPYABLE_H__ namespace wd { class Noncopy ...

  2. BZOJ2877:[NOI2012]魔幻棋盘

    浅谈树状数组与主席树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://lydsy.com/JudgeOnline/problem. ...

  3. AtCoder Grand Contest 010 C:Cleaning

    题目传送门:https://agc010.contest.atcoder.jp/tasks/agc010_c 题目翻译 给你一棵树,每个点有个权值,每次操作可以选择两个度数为\(1\)的结点,然后让这 ...

  4. Python调试指南

    http://blog.sina.com.cn/s/blog_a15aa56901017u0p.html http://www.cnblogs.com/coderzh/archive/2009/12/ ...

  5. PowerShell自动部署网站—(1)、安装IIS[添加角色和角色服务]

    #------添加角色/角色服务------ Import-Module servermanager $features = get-windowsfeature Net-*,Telnet-*,Web ...

  6. Oracle数据库导入、导出(远程、10g、11g)

    1  查看oracle的版本信息 (1)用客户端连接到数据库,执行select * from v$instance             查看version项 (2)select * from pr ...

  7. python2 + selenium + eclipse 中,配置好runserver 127.0.0.1:9000,运行的时候,报错

    python2 + selenium + eclipse 中,配置好runserver 127.0.0.1:9000,运行的时候,报错,如图: 原因:       google发现是WSGI appl ...

  8. tomcat 开机自启方法

    1.把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat. #!/bin/bash # # /etc/rc.d/init.d/tomcat # init scri ...

  9. 小程序[邮箱提取器-EmailSplider]总结

    1.背景情况     学东西做快的是付诸实践,写这个小程序的目的就是为了综合运用各个知识点,从而提升学习的效果.   2.涉及知识     A.Swing 的布局     B.Swing中,线程访问U ...

  10. 如何使用jmeter连接数据库并提取数据库中的值作为参数,与响应信息中提取的值进行比较

    思路: 连接数据库 获取数据库返回的数据 获取接口返回的数据 两者返回数据进行对比验证 连接数据库 1.jmeter要链接mysql数据库,首先得下载mysql jdbc驱动包(注:驱动包的版本一定要 ...