没有合适的资源?快使用搜索试试~ 我知道了~
[] - 2023-01-31 Spring Boot Admin 服务监控利器 !.pdf
需积分: 0 0 下载量 56 浏览量
2023-12-11
21:37:36
上传
评论
收藏 1.18MB PDF 举报
温馨提示
试读
16页
互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能互联网资讯,技术简介,IT、AI技术,人工智能
资源推荐
资源详情
资源评论
Spring Boot Admin 服务监控利器 !
用 于 对 S p r i n g B o o t
应 用 的 管 理 和 监 控 。 可 以 用 来 监 控 服 务 是 否 健 康 、 是 否 在 线 、 以
及 一 些 j v m 数 据 等 等 。
S p r i n g B o o t A d m i n 分 为 服 务 端 ( s p r i n g - b o o t - a d m i n -
s e r v e r ) 和 客 户 端 ( s p r i n g - b o o t - a d m i n -
c l i e n t ) , 服 务 端 和 客 户 端 之 间 采 用 h t t p
通 讯 方 式 实 现 数 据 交 互 ; 单 体 项 目 中 需 要 整 合 s p r i n g - b o o t -
a d m i n - c l i e n t 才 能 让 应 用 被 监 控 。
在 S p r i n g C l o u d 项 目 中 , s p r i n g - b o o t - a d m i n - s e r v e r
是 直 接 从 注 册 中 心 抓 取 应 用 信 息 , 不 需 要 每 个 微 服 务 应 用 整 合
s p r i n g - b o o t - a d m i n - c l i e n t 就 可 以 实 现 应 用 的 管 理 和 监 控 。
图片
主 要 的 功 能 点 有 :
显示应用程序的监控状态
应用程序上下线监控
查看 JVM,线程信息
可视化的查看日志以及下载日志文件
动态切换日志级别
Http 请求信息跟踪
二、搭建
1、服务端
需 先 搭 建 服 务 端 , 监 控 服 务 , 被 监 控 的 服 务 连 接 过 来 即 可 , 开 箱
即 用 。
1 、 新 建 一 个 项 目 做 为 服 务 端
2 、 引 入 s p r i n g - b o o t - a d m i n 服 务 端 依 赖
<!--用于检查系统的监控情况-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--Spring Boot Admin Server监控服务端-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.3.1</version>
</dependency>
<!--增加安全防护,防止别人随便进-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
3 、 启 动 类 上 开 启 a d m i n @ E n a b l e A d m i n S e r v e r
4 、 s e c u r i t y 安 全 防 护 配 置
import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecur
ity;
import org.springframework.security.config.annotation.web.configuration.WebS
ecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuth
enticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
@Configuration
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
private final String adminContextPath;
public SecuritySecureConfig(AdminServerProperties adminServerProperties)
{
this.adminContextPath = adminServerProperties.getContextPath();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// 登录成功处理类
SavedRequestAwareAuthenticationSuccessHandler successHandler = new S
avedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
http.authorizeRequests()
//静态文件允许访问
.antMatchers(adminContextPath + "/assets/**").permitAll()
//登录页面允许访问
.antMatchers(adminContextPath + "/login", "/css/**", "/js/**
", "/image/*").permitAll()
//其他所有请求需要登录
.anyRequest().authenticated()
.and()
//登录页面配置,用于替换security默认页面
.formLogin().loginPage(adminContextPath + "/login").successH
andler(successHandler).and()
//登出页面配置,用于替换security默认页面
.logout().logoutUrl(adminContextPath + "/logout").and()
.httpBasic().and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyF
alse())
.ignoringAntMatchers(
"/instances",
"/actuator/**"
);
}
}
5 、 y m l 配 置
server:
port: 9111
spring:
boot:
admin:
ui:
title: HMB服务监控中心
client:
instance:
metadata:
tags:
environment: local
#
要获取的
client
的端点信息
probed-
endpoints: health,env,metrics,httptrace:trace,threaddump:dump,jolokia,info,l
ogfile,refresh,flyway,liquibase,heapdump,loggers,auditevents
monitor: #
监控发送请求的超时时间
default-timeout: 20000
security: #
设置账号密码
user:
name: admin
password: admin
剩余15页未读,继续阅读
资源评论
毕业小助手
- 粉丝: 2081
- 资源: 1712
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功