Spring Boot Admin Best Practices

This article does not conduct Spring Boot Admin introductory knowledge statements

In Spring Boot Actuatorproviding many as in health, metricsreal-time monitoring interface, you can easily keep track of the performance of our services. Spring BootThe default is to open these interfaces provide called, then the question is, if these interface exposes a foreign network, can easily be exploited by criminals, this is certainly not the result we want. Here we provide a better solution.

  • Monitored service configuration

Request to add the prefix http request be protected

1
2
3
4
5
6
management:
context-path: /example-context
eureka:
instance:
status-page-url-path: ${management.context-path}/info
health-check-url-path: ${management.context-path}/health
  1. Request to add a prefix
  2. Spring Boot AdminAt startup will go eurekagot me to the service information, healthand inforequire special handling, both of which are based on the address status-page-url-pathand health-check-url-pathvalue.
  • zuulGateway Configuration

zuulInternal protection service http Interface

1
2
zuul:
ignoredPatterns: /*/example-context/**
  1. The reason here is not /example-context/**due to the presence prefix Gateway project, a need to move forward, you can configure specific scenarios specific
  • Spring Boot AdminConfiguration

Configuration parameters monitored indicators

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
spring:< 大专栏  Spring Boot Admin最佳实践/span>
application:
name: monitor
boot:
admin:
discovery:
converter:
management-context-path: /example-context
routes:
endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream
turbine:
clusters: default
location: monitor

turbine:
aggregator:
clusterConfig: default
appConfig: monitor-example #<2>
clusterNameExpression: metadata['cluster']
  1. And application configuration management.context-pathidentical
  2. Adding applications to be monitored Service-Id, separated by commas

Explain, by creating a request prefix, you can use the prefix at the gateway ways to exclude, which is outside the network can not access those monitoring API, at the same time, the network can still be prefixed way access for Spring Boot Adminproviding support condition. managementAlso supports port and ip way, but there are limitations in two ways, if the deployment of multiple services on the same machine, it will occupy the port or other problems exist. This approach also has the benefit above configuration Once defined, all services do not require specialized treatment, it can be used directly.

Q & A:

  • 问题:Full authentication is required to access this resource

Further Reading:

spring-boot-admin-samples

issue

jolokia

Guess you like

Origin www.cnblogs.com/lijianming180/p/12014196.html