标签:事件 ons 次数 垃圾 monit depend htm logger yml
本文只是介绍最基本的使用
<!--nacos-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--admin端的依赖-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
server:
port: 9000
spring:
application:
name: cloud-monitoring-admin
cloud:
nacos:
discovery:
#配置Nacos地址
server-addr: localhost:18848
# 测试暴露所有端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
@SpringBootApplication( exclude = {DataSourceAutoConfiguration.class})
@EnableDiscoveryClient
//该注解启动监控
@EnableAdminServer
public class MonitoringAdminApplication {
public static void main(String[] args) {
SpringApplication.run(MonitoringAdminApplication.class,args);
}
}
监控admin端已经搭建成功
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
server:
port: 9002
spring:
application:
name: cloud-monitoring-client-02
cloud:
nacos:
discovery:
server-addr: localhost:18848 #配置Nacos地址
#监控暴漏所有端点
management:
endpoints:
web:
exposure:
include: ‘*‘
endpoint:
health:
show-details: ALWAYS
# 启动日志任务
logfile:
enabled: true
#日志的配置
logging:
file:
name: RiestSpringWeb.log.2020-11-20.0.log
pattern:
#日志格式
file: ‘%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID}){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx‘
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableDiscoveryClient
public class MonitoringClient02Application {
public static void main(String[] args) {
SpringApplication.run(MonitoringClient02Application.class, args);
}
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
server:
port: 9000
spring:
application:
name: cloud-monitoring-admin
cloud:
nacos:
discovery:
server-addr: localhost:18848 #配置Nacos地址
# 开启springbootadmin的邮件任务
boot:
admin:
notify:
mail:
# 逗号分隔的邮件收件人列表
to: 2575101192@qq.com
# 开启邮箱通知
enabled: true
# 不需要发送通知的状态:从状态A:到状态B
ignore-changes: {"UNKNOWN:UP"}
# 逗号分隔的抄送收件人列表
# cc: 2575101192@qq.com
# 发件人
from: 2575101192@qq.com
#邮件模板
template: "classpath:templates/RegisterSuccess.html"
mail:
host: smtp.qq.com
port: 465
username: 2575101192@qq.com
default-encoding: utf-8
# 密码配置成授权码
password: qq邮箱授权码
properties:
mail:
smtp:
ssl:
enable: true
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>注册成功通知</title>
</head>
<body>
<p>您好!
</p>
<p>
springbootadmin监控:<br/>
标题: xxx应用下线 <br/>
请检查!!!
</p>
</body>
</html>
后续收到对应的邮件通知
TO BE CONTINUED
标签:事件 ons 次数 垃圾 monit depend htm logger yml
原文地址:https://www.cnblogs.com/dgjword/p/14016016.html