国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

2022-03-06 13:16一張船票 Java教程

本文主要介紹了SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

基于SpringCloud微服務平臺,進行服務實例監控及健康檢查,注冊中心為eureka,SpringBoot提供了很好的組件SpringBoot Admin,2.X版本直接可以配置釘釘機器人告警。

效果:可以實現eureka注冊的實例上線、下線觸發釘釘告警。監控我們的服務實例健康檢查。

搭建admin-server

pom依賴

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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監控eureka服務實例和健康檢查,釘釘告警</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配置

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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=釘釘機器人access_token'
          secret: '釘釘機器人secret'
          message: '服務告警: #{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

啟動類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
    }
}

啟動后效果

SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警

到此這篇關于SpringBoot-Admin實現微服務監控+健康檢查+釘釘告警的文章就介紹到這了,更多相關SpringBoot-Admin 微服務監控內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/XinTeng2012/article/details/120988806

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 中文字幕99| 一级大片av | 国产免费一区二区 | 国产精品久久久久久久一区探花 | 久久水蜜桃 | 美国理论 | 一区二区三区视频 | 久久精品国产清自在天天线 | 色婷婷国产精品免费网站 | 欧美日韩综合一区 | 国产精品成人3p一区二区三区 | 国产毛片一区二区 | 91看片| 亚洲精品乱码久久久久久麻豆不卡 | 国产精品精品视频一区二区三区 | av一级毛片 | 日本在线小视频 | 玖玖综合网 | 日本黄色大片免费 | 国产伦精品一区二区三区精品视频 | 日韩av一区二区在线观看 | 日本二区视频 | a视频在线观看 | 日韩精品一区在线 | 亚洲一区二区三区在线 | av在线一区二区三区 | 久久久精品一区二区 | 亚洲人人 | 人人澡人人射 | 国产综合一区二区 | 国产一级在线 | 精品久久久久久久久久久 | 一片毛片 | 欧美亚洲国产一区二区三区 | 九一视频在线免费观看 | 亚洲一一在线 | 国产精品成人国产乱一区 | 欧美黑人性暴力猛交喷水 | 久久成人18免费网站 | 精品一区二区三区免费视频 | 国产又色又爽又黄又免费 |