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. codevs2189数字三角形w——最优性转化

    题目:http://codevs.cn/problem/2189/ 通过增加一维,将最优性转化为可行性. 代码如下: #include<iostream> #include<cstd ...

  2. JMeter聚合报告(Aggregate Report)理解

    部分内容转载: http://blog.csdn.net/lion19930924/article/details/51189218 http://www.cnblogs.com/fnng/archi ...

  3. POJ-3069

    Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10994   Accepted: 5555 D ...

  4. wpf窗口禁止最大化但允许调整大小

    wpf中窗口禁止最大化可以通过属性ResizeMode来设置,但是ResizeMode有一个问题就是如果ResizeMode设置为NoResize的话,是可以禁止最大化的,但是这样同时也就不能拖动调整 ...

  5. NativeScript官方书籍:1.为什么选择nativescript

    1.为什么选择nativescript 本章介绍 什么是NativeScript nativescript对于移动开发世界意味着什么 NativeScript工作原理 在早期的移动应用程序(前iPho ...

  6. A Beginner's Guide to HTTP and REST

    http://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340 Hypertext Transfer ...

  7. SQL将一个表中的某一列值全部插入到另一个表中

    1.  SQL将一个表中的某一列值全部插入到另一个表中 插入的话: insert into a(col) select col from b; 更新的话: update a set col=selec ...

  8. HTML前端入门归纳——控件

    本人一直在从事.net的开发,界面都是采用的WPF,近期花了一个多月进行HTML前端的学习,在这里呢进行学习总结和归纳. 本系列将主要分为4个模块: 控件 样式 布局 JavaScript 根据多年W ...

  9. ue4 fuck

    https://answers.unrealengine.com/questions/661969/uspringarmcomponent-ucameracomponent-not-identifie ...

  10. CodeForces - 820

    Mister B and Book ReadingCodeForces - 820A 题意:C,V0,V1,A,L..总共有C页书,第一天以V0速度读,每天加A,但是不能超过V1,并且要从前一天的看到 ...