当前位置: 首页 > news >正文

用mediawiki做的网站哈尔滨网站建设贴吧

用mediawiki做的网站,哈尔滨网站建设贴吧,打开部分网站很慢,推进网站集约化建设的作用前言 本文将会使用 Spring Boot Actuator 组件实现应用监视和管理#xff0c;同时结合 Spring Boot Admin 对 Actuator 中的信息进行界面化展示#xff0c;监控应用的健康状况#xff0c;提供实时警报功能 Spring Boot Actuator 简介 官方文档#xff1a;Production-rea…前言 本文将会使用 Spring Boot Actuator 组件实现应用监视和管理同时结合 Spring Boot Admin 对 Actuator 中的信息进行界面化展示监控应用的健康状况提供实时警报功能 Spring Boot Actuator 简介 官方文档Production-ready Features (spring.io) Actuator 的核心是端点Endpoint它用来监视、提供应用程序的信息Spring Boot 提供的 spring-boot-actuator 组件中已经内置了非常多的 Endpointhealth、info、beans、metrics、httptrace、shutdown 等每个端点都可以启用和禁用。Actuator 也允许我们扩展自己的端点。通过 JMX 或 HTTP 的形式暴露自定义端点 注查看全部 Endpoints 请参照上方的官方文档 Actuator 会将自定义端点的 ID 默认映射到一个带 /actuator 前缀的 URL。比如health 端点默认映射到 /actuator/health。这样就可以通过 HTTP 的形式获取自定义端点的数据许多网关作为反向代理需要 URL 来探测后端集群应用是否存活这个 URL 就可以提供给网关使用 启动端点 默认情况下除shutdown之外的所有终结点都处于启用状态。若要配置终结点的启用请使用其  management.endpoint.id.enabled  属性。以下示例启用终结点  shutdown management:endpoint:shutdown:enabled: true如果您希望端点启用选择加入而不是选择退出请将该  management.endpoints.enabled-by-default  属性设置为  false  并使用单个端点  enabled  属性选择重新加入。以下示例启用该  info  终结点并禁用所有其他终结点 management:endpoints:enabled-by-default: falseendpoint:info:enabled: true注禁用的端点将从应用程序上下文中完全删除。如果只想更改公开终结点的技术请改用  include  和  exclude  属性。 公开端点 禁用的端点将从应用程序上下文中完全删除。如果只想更改公开终结点的技术请改用 include 和 exclude 属性。若要更改公开的终结点请使用以下特定于 include 技术的 exclude 属性 include 属性列出了公开的终结点的 ID。exclude 属性列出了不应公开的终结点的 ID。 exclude 属性优先于该 include 属性。您可以使用端点 ID 列表配置属性和 exclude 属性 include 。 例如要仅通过 JMX 公开  health  和  info  端点请使用以下属性 management:endpoints:jmx:exposure:include: health,info*可用于选择所有端点。例如若要通过 HTTP 公开除 env 和 beans 终结点之外的所有内容请使用以下属性 management:endpoints:web:exposure:include: *exclude: env,beansActuator 同时还可以与外部应用监控系统整合比如 Prometheus, Graphite, DataDog, Influx, Wavefront, New Relic 等。这些系统提供了非常好的仪表盘、图标、分析和告警等功能使得你可以通过统一的接口轻松的监控和管理你的应用系统。这对于实施微服务的中小团队来说无疑快速高效的解决方案 配置集成 首先我们需要创建 springboot web 项目然后 pom.xml 中添加如下 actuator 依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId /dependency配置 application.yml server:port: 8080management:endpoints:enabled-by-default: falseweb:base-path: /manageexposure:include: info,health,env,beansendpoint:info:enabled: truehealth:enabled: trueenv:enabled: truebeans:enabled: true上述配置只暴露 info,health,env,beans 四个 endpoints, web 通过可以 /manage 访问 访问localhost:8080/manage 查看所有开放的端点 {_links: {self: {href: http://localhost:8080/manage,templated: false},beans: {href: http://localhost:8080/manage/beans,templated: false},health: {href: http://localhost:8080/manage/health,templated: false},health-path: {href: http://localhost:8080/manage/health/{*path},templated: true},info: {href: http://localhost:8080/manage/info,templated: false},env: {href: http://localhost:8080/manage/env,templated: false},env-toMatch: {href: http://localhost:8080/manage/env/{toMatch},templated: true}} }访问localhost:8080/manage/beans 拓展配置 安全性 当我们想要暴露更多接口同时保证 endpoint 接口安全可以与 Spring Security 集成 Configuration(proxyBeanMethods false) public class MySecurityConfiguration {Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests((requests) - requests.anyRequest().hasRole(ENDPOINT_ADMIN));http.httpBasic();return http.build();}}此外如果存在 Spring Security同时你需要添加自定义安全配置以允许对端点进行未经身份验证的访问如以下示例所示 Configuration(proxyBeanMethods false) public class MySecurityConfiguration {Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {http.securityMatcher(EndpointRequest.toAnyEndpoint());http.authorizeHttpRequests((requests) - requests.anyRequest().permitAll());return http.build();}}跨域访问 management:endpoints:web:cors:allowed-origins: https://example.comallowed-methods: GET,POST自定义端点 我们可以通过JmxEndpoint or WebEndpoint 注解来定义自己的 endpoint, 然后通过ReadOperation, WriteOperation 或者DeleteOperation 来暴露操作 比如添加系统时间 date 的 endpoint RestController(custom) WebEndpoint(id date) public class CustomEndpointController {ReadOperationpublic ResponseEntityString currentDate() {return ResponseEntity.ok(LocalDateTime.now().toString());} }management:endpoints:enabled-by-default: falseweb:base-path: /manageexposure:include: info,health,env,beans,dateendpoint:info:enabled: truehealth:enabled: trueenv:enabled: truebeans:enabled: truedate:enabled: trueinfo 不显示 我们直接访问 info 接口是空的 问题出处官方文档Production-ready Features (spring.io) 解决方案修改 application.yml 如下 management:endpoint:info:env:enabled: trueSpring Boot Admin 简介 官方仓库codecentric/spring-boot-admin 官方文档Spring Boot Admin – (spring-boot-admin.com) Spring Boot Admin简称 SBA由两部分组成SBA Server 和 SBA Client SBA Server 包括 Admin 用户界面并独立运行于被监控应用 SBA Client 提供一种方式将被监控应用注册到 SBA Server SBA 分为服务端和客户端原理因为 SBA 需要做集中化的监控比如应用的集群多个服务或者微服务等而不是每个应用都需要有一个 UI。同时被监控的应用应该是和监控平台是分离的并且需要考虑其他语言和其他平台的集成 除此之外SBA Client 不仅只可以注册到 SBA Server 还可以注册到 Spring Cloud Discovery微服务Python Applications Using Pyctuator其他语言等平台 启用 Server pom.xml 配置 dependencygroupIdde.codecentric/groupIdartifactIdspring-boot-admin-starter-server/artifactIdversion2.5.3/version /dependency注意这里我们必须添加 version 字段因为父模块 spring-boot-starter-parent 中的 BOMBill of Material 并没有配置 SBA 的 version无法自动识别 通过 EnableAdminServer 注解启用 SBA Server Configuration EnableAdminServer SpringBootApplication public class SpringBootActuatorDemoApplication {public static void main(String[] args) {SpringApplication.run(SpringBootActuatorDemoApplication.class, args);}}访问Spring Boot Admin 注册 Client 引入 SBA Client 依赖 dependencygroupIdde.codecentric/groupIdartifactIdspring-boot-admin-starter-client/artifactIdversion2.5.3/version /dependency配置 application.yml server:port: 8080management:endpoints:enabled-by-default: falseweb:base-path: /manageexposure:include: info,health,env,beansendpoint:info:env:enabled: trueenabled: truehealth:enabled: trueenv:enabled: truebeans:enabled: true # 添加如下配置 spring:boot:admin:client:url: http://localhost:8080访问Spring Boot Admin 之后点击进入实例可以自行探索监控信息 其他问题 启用 JMX 管理 默认下 SBA 没有启用 JMX需要通过如下配置启用。 首先需要引入 POM 依赖PS需要 SpringBoot2.2 版本 dependencygroupIdorg.jolokia/groupIdartifactIdjolokia-core/artifactId /dependencyyml 配置 spring:jmx:enabled: true显示日志内容 默认下没有显示 Log File 的内容如果需要显示 SpringBoot 应用日志需要进行如下配置配置 logging.file.path 或者 logging.file.name logging:file:name: pdai-spring-boot-application.logpattern: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继承 Spring Security dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-security/artifactId /dependencyConfiguration public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().anyRequest().permitAll() .and().csrf().disable();} }通知告警信息 集成 spring-boot-starter-mail 配置 JavaMailSender 来用邮件通知信息 官方文档对应链接Spring Boot Admin – (spring-boot-admin.com) dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId /dependencyspring:mail:host:smtp.example.comboot:admin:notify:mail:to:adminexample.com注更多通知方式钉钉微信等可以直接参考上方官方文档 补充 在生产环境下使用 Prometheus Grafana 组合也是非常推荐的监控解决方案这里篇章有限读者可以自行探索 参考链接 SpringBoot 监控 - 集成 actuator 监控工具 | Java 全栈知识体系 (pdai.tech)SpringBoot 监控 - 集成 springboot admin 监控工具 | Java 全栈知识体系 (pdai.tech)微服务系列服务监控 Spring Boot Actuator 和 Spring Boot Admin - 掘金 (juejin.cn)实战使用 Spring Boot Admin 实现运维监控平台-阿里云开发者社区 (aliyun.com)Prometheus 快速入门教程六Spring Boot Actuator 实现应用监控Prometheus简介 - prometheus-book (gitbook.io) 本文由博客一文多发平台 OpenWrite 发布
http://wiki.neutronadmin.com/news/278878/

相关文章:

  • 视频网站开发用什么服务器百度申请qq号免费注册
  • 石家庄市制作网站公司淘宝的网站怎么做的好
  • 怎么建设大型商务网站银川seo公司
  • 做衣服 网站给企业做网站
  • 保山网站建设多少钱外包网站问些什么问题
  • 网站制作哪家好建筑建设行业网站
  • 用手机可以做网站顺义企业建站费用
  • 做外贸网站的好处做pc端网站好么
  • 网站建设图片编辑白银做网站的董事
  • 郑州正规的网站设计app软件开发不包括
  • 金湖做网站网站建设服务器租用
  • 网站 国外空间不需要icp许可证吗廊坊市固安县建设局网站
  • 建设部网站是什么网站怎么在百度网站上做自己的网站
  • 西宁建设工程官方网站外贸怎么做站外推广
  • 新开传奇网站发布站手游社交网站图片展示
  • 网站 目录 结构义乌百度网站制作
  • vps网站打开需要身份验证石家庄科技中心网站
  • 贵州安顺做公司网站2018网站建设行业
  • 网站上传办法东莞seo按天计费
  • 哈尔滨寸金网站建设公司口碑酒店专业培训网站建设
  • 如何做一家专门卖零食的网站顺德品牌网站建设咨询
  • 天水模板型网站建设WordPress改成淘宝客
  • 网站解析密码注册一个公司需要几个人
  • joomla做的网站网站服务器类型查询
  • 广州网站建设乐云seo专门做餐饮运营的网站
  • 网站常规seo优化步骤温州制作网站公司
  • 安徽省建设造价管理协会网站张店网站建设yx718
  • 网站后期的维护和更新自己建立网站要钱吗
  • 做网站 怎么连到数据库页面简单的网站模板免费下载
  • 北京网站改版有哪些好处蜘蛛搜索引擎网页版