最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot-Admin實(shí)現(xiàn)微服務(wù)監(jiān)控+健康檢查+釘釘告警

 更新時(shí)間:2021年10月29日 15:21:03   作者:一張船票  
本文主要介紹了SpringBoot-Admin實(shí)現(xiàn)微服務(wù)監(jiān)控+健康檢查+釘釘告警,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

基于SpringCloud微服務(wù)平臺(tái),進(jìn)行服務(wù)實(shí)例監(jiān)控及健康檢查,注冊(cè)中心為eureka,SpringBoot提供了很好的組件SpringBoot Admin,2.X版本直接可以配置釘釘機(jī)器人告警。

效果:可以實(shí)現(xiàn)eureka注冊(cè)的實(shí)例上線、下線觸發(fā)釘釘告警。監(jiān)控我們的服務(wù)實(shí)例健康檢查。

搭建admin-server

pom依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.11</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>admin-server</artifactId>
	<version>1.0.0</version>
	<name>etc-admin-server</name>
	<description>Spring Boot Admin監(jiān)控eureka服務(wù)實(shí)例和健康檢查,釘釘告警</description>
	<properties>
		<java.version>1.8</java.version>
		<spring-boot-admin.version>2.4.3</spring-boot-admin.version>
		<spring-cloud.version>2020.0.4</spring-cloud.version>
	</properties>
	<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-starter-server</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>de.codecentric</groupId>
				<artifactId>spring-boot-admin-dependencies</artifactId>
				<version>${spring-boot-admin.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
        <finalName>${project.name}</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>

application.yml配置

spring:
  application:
    name: admin-server
  security:
    user:
      name: "admin"
      password: "pwd"

  boot:
    admin:
      notify:
        dingtalk:
          enabled: true
          webhookUrl: 'https://oapi.dingtalk.com/robot/send?access_token=釘釘機(jī)器人access_token'
          secret: '釘釘機(jī)器人secret'
          message: '服務(wù)告警: #{instance.registration.name} #{instance.id} is #{event.statusInfo.status}'
server:
  port: 9002

eureka:
  client:
    registryFetchIntervalSeconds: 5
    service-url:
      defaultZone: 'http://127.0.0.1:8020/eureka/'
  instance:
    hostname: ${spring.cloud.client.ip-address}
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
    prefer-ip-address: true
    ip-address: ${spring.cloud.client.ip-address}
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
    metadata-map:
      user.name: ${spring.security.user.name}
      user.password: ${spring.security.user.password}

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

啟動(dòng)類

package com.example;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * @author xxx
 */
@EnableAdminServer
@EnableDiscoveryClient
@SpringBootApplication
public class AdminServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(AdminServerApplication.class, args);
	}
}

config類

package com.example;

import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;

/**
 * WebSecurity配置
 * @author xxxx
 */
@Configuration
public class WebSecurityConfigure extends WebSecurityConfigurerAdapter {

    private final String adminContextPath;

    public WebSecurityConfigure(AdminServerProperties adminServerProperties) {
        this.adminContextPath = adminServerProperties.getContextPath();
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // @formatter:off
        SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
        successHandler.setTargetUrlParameter("redirectTo");
        successHandler.setDefaultTargetUrl(adminContextPath + "/");

        http.authorizeRequests()
                .antMatchers(adminContextPath + "/assets/**").permitAll()
                .antMatchers(adminContextPath + "/login").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
                .logout().logoutUrl(adminContextPath + "/logout").and()
                .httpBasic().and()
                .csrf()
                .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
                .ignoringAntMatchers(
                        adminContextPath + "/instances",
                        adminContextPath + "/actuator/**"
                );
        // @formatter:on
    }
}

啟動(dòng)后效果

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

到此這篇關(guān)于SpringBoot-Admin實(shí)現(xiàn)微服務(wù)監(jiān)控+健康檢查+釘釘告警的文章就介紹到這了,更多相關(guān)SpringBoot-Admin 微服務(wù)監(jiān)控內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java迭代器中刪除元素的實(shí)例操作詳解

    java迭代器中刪除元素的實(shí)例操作詳解

    在本篇內(nèi)容里小編給各位分享了一篇關(guān)于java迭代器中刪除元素的實(shí)例操作詳解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。
    2021-01-01
  • Java簡(jiǎn)單驗(yàn)證身份證功能示例

    Java簡(jiǎn)單驗(yàn)證身份證功能示例

    這篇文章主要介紹了Java簡(jiǎn)單驗(yàn)證身份證功能,涉及java針對(duì)字符串的截取、判斷相關(guān)操作技巧,需要的朋友可以參考下
    2017-06-06
  • Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例

    Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例

    下面小編就為大家分享一篇Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助
    2017-11-11
  • SpringBoot使用Redis對(duì)用戶IP進(jìn)行接口限流的示例詳解

    SpringBoot使用Redis對(duì)用戶IP進(jìn)行接口限流的示例詳解

    使用接口限流的主要目的在于提高系統(tǒng)的穩(wěn)定性,防止接口被惡意打擊,這篇文章主要介紹了SpringBoot使用Redis對(duì)用戶IP進(jìn)行接口限流的示例代碼,需要的朋友可以參考下
    2023-07-07
  • Java實(shí)現(xiàn)5種限流算法及7種限流方式

    Java實(shí)現(xiàn)5種限流算法及7種限流方式

    本文主要介紹了Java實(shí)現(xiàn)5種限流算法及7種限流方式,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • profiles.active多環(huán)境開發(fā)、測(cè)試、部署過程

    profiles.active多環(huán)境開發(fā)、測(cè)試、部署過程

    這篇文章主要介紹了profiles.active多環(huán)境開發(fā)、測(cè)試、部署,主要講如何使用profiles.active這個(gè)變量,讓我們?cè)陂_發(fā)過程快速切換環(huán)境配置,以及如何使一個(gè)部署適配各種不同的環(huán)境,需要的朋友可以參考下
    2023-03-03
  • maven多profile 打包下 -P參和-D參數(shù)的實(shí)現(xiàn)

    maven多profile 打包下 -P參和-D參數(shù)的實(shí)現(xiàn)

    這篇文章主要介紹了maven多profile 打包下 -P參和-D參數(shù)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • Springboot應(yīng)用中線程池配置詳細(xì)教程(最新2021版)

    Springboot應(yīng)用中線程池配置詳細(xì)教程(最新2021版)

    這篇文章主要介紹了Springboot應(yīng)用中線程池配置教程(2021版),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • Spring boot集成Mybatis的方法教程

    Spring boot集成Mybatis的方法教程

    這篇文章主要給大家介紹了Spring boot集成Mybatis的方法教程,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來一起看看吧。
    2017-04-04
  • Java超詳細(xì)分析繼承與重寫的特點(diǎn)

    Java超詳細(xì)分析繼承與重寫的特點(diǎn)

    繼承是Java面向?qū)ο缶幊讨械囊婚T。繼承是子類繼承父類的特征和行為,或者是繼承父類得方法,使的子類具有父類得的特性和行為。重寫是子類對(duì)父類的允許訪問的方法實(shí)行的過程進(jìn)行重新編寫,返回值和形參都不能改變。就是對(duì)原本的父類進(jìn)行重新編寫,但是外部接口不能被重寫
    2022-05-05

最新評(píng)論

弥勒县| 焉耆| 汾西县| 洪泽县| 茶陵县| 连州市| 云龙县| 临高县| 固原市| 温宿县| 广平县| 辛集市| 云南省| 景德镇市| 陕西省| 都江堰市| 察雅县| 桂林市| 江永县| 绥中县| 古蔺县| 随州市| 望城县| 香河县| 吴川市| 永丰县| 琼中| 普安县| 井冈山市| 寿阳县| 名山县| 东丽区| 无为县| 黔西县| 漾濞| 乌拉特前旗| 广饶县| 康保县| 三门峡市| 新建县| 清水县|