From ed779c5891a4fc7b2fc06fcf649c780ef6971dfc Mon Sep 17 00:00:00 2001 From: "Jared.Tan" Date: Thu, 8 Aug 2019 15:50:03 +0800 Subject: [PATCH 1/3] add prometheus integration. --- .../apollo/common/controller/WebMvcConfig.java | 6 ++---- .../src/main/resources/application.properties | 2 ++ .../spi/configuration/AuthConfiguration.java | 2 +- apollo-portal/src/main/resources/application.yml | 2 +- pom.xml | 15 +++++++++++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java index 7f556da690e..964fde95c82 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java @@ -1,19 +1,17 @@ package com.ctrip.framework.apollo.common.controller; +import java.util.List; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.server.MimeMappings; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.context.annotation.Configuration; import org.springframework.data.domain.PageRequest; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; -import org.springframework.http.MediaType; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import java.util.List; - @Configuration public class WebMvcConfig implements WebMvcConfigurer, WebServerFactoryCustomizer { @@ -29,7 +27,7 @@ public void addArgumentResolvers(List argumentRes @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false); - configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON_UTF8); + //configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON_UTF8); } @Override diff --git a/apollo-common/src/main/resources/application.properties b/apollo-common/src/main/resources/application.properties index 27bdd5a6ee5..b96dd9132e2 100644 --- a/apollo-common/src/main/resources/application.properties +++ b/apollo-common/src/main/resources/application.properties @@ -17,3 +17,5 @@ server.max-http-header-size=10240 management.endpoints.web.base-path=/ logging.file.max-size=50MB logging.file.max-history=10 + +management.endpoints.web.exposure.include=* \ No newline at end of file diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java index 73d5403fea3..b3b07135051 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java @@ -271,7 +271,7 @@ protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.headers().frameOptions().sameOrigin(); http.authorizeRequests() - .antMatchers("/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**").permitAll() + .antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**").permitAll() .antMatchers("/**").hasAnyRole(USER_ROLE); http.formLogin().loginPage("/signin").permitAll().failureUrl("/signin?#/error").and().httpBasic(); SimpleUrlLogoutSuccessHandler urlLogoutHandler = new SimpleUrlLogoutSuccessHandler(); diff --git a/apollo-portal/src/main/resources/application.yml b/apollo-portal/src/main/resources/application.yml index a53e9525952..608871ba749 100644 --- a/apollo-portal/src/main/resources/application.yml +++ b/apollo-portal/src/main/resources/application.yml @@ -22,6 +22,6 @@ logging: management: health: status: - order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP + order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP diff --git a/pom.xml b/pom.xml index 63bfc3e1b79..2d55ceed0fa 100644 --- a/pom.xml +++ b/pom.xml @@ -362,6 +362,21 @@ + + + + org.springframework.boot + spring-boot-starter-actuator + + + + io.micrometer + micrometer-core + + + io.micrometer + micrometer-registry-prometheus + From d1f5b236faf43032f5f68c35f1abcadc1be18634 Mon Sep 17 00:00:00 2001 From: "Jared.Tan" Date: Sun, 11 Aug 2019 10:48:02 +0800 Subject: [PATCH 2/3] fix ci. --- apollo-common/pom.xml | 15 +++++++++++++++ .../apollo/common/controller/WebMvcConfig.java | 1 - .../src/main/resources/application.properties | 4 +++- pom.xml | 15 --------------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/apollo-common/pom.xml b/apollo-common/pom.xml index 1d80968b7d0..fd82515ebe8 100644 --- a/apollo-common/pom.xml +++ b/apollo-common/pom.xml @@ -60,5 +60,20 @@ commons-lang commons-lang + + + + org.springframework.boot + spring-boot-starter-actuator + + + + io.micrometer + micrometer-core + + + io.micrometer + micrometer-registry-prometheus + diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java index 964fde95c82..a965b4323dd 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java @@ -27,7 +27,6 @@ public void addArgumentResolvers(List argumentRes @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false); - //configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON_UTF8); } @Override diff --git a/apollo-common/src/main/resources/application.properties b/apollo-common/src/main/resources/application.properties index b96dd9132e2..34a37edb408 100644 --- a/apollo-common/src/main/resources/application.properties +++ b/apollo-common/src/main/resources/application.properties @@ -18,4 +18,6 @@ management.endpoints.web.base-path=/ logging.file.max-size=50MB logging.file.max-history=10 -management.endpoints.web.exposure.include=* \ No newline at end of file +management.endpoints.web.exposure.include=info,health,metrics,prometheus +management.endpoint.metrics.enabled=true +management.endpoint.prometheus.enabled=true diff --git a/pom.xml b/pom.xml index 2d55ceed0fa..63bfc3e1b79 100644 --- a/pom.xml +++ b/pom.xml @@ -362,21 +362,6 @@ - - - - org.springframework.boot - spring-boot-starter-actuator - - - - io.micrometer - micrometer-core - - - io.micrometer - micrometer-registry-prometheus - From 0164bc3b8fb3ec179706948e03844cd0a0c53af9 Mon Sep 17 00:00:00 2001 From: "Jared.Tan" Date: Sun, 11 Aug 2019 22:36:11 +0800 Subject: [PATCH 3/3] remove duplicate actuator dependency. --- apollo-common/pom.xml | 7 +------ apollo-common/src/main/resources/application.properties | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/apollo-common/pom.xml b/apollo-common/pom.xml index fd82515ebe8..28fdd6aa41f 100644 --- a/apollo-common/pom.xml +++ b/apollo-common/pom.xml @@ -61,12 +61,7 @@ commons-lang - - - org.springframework.boot - spring-boot-starter-actuator - - + io.micrometer micrometer-core diff --git a/apollo-common/src/main/resources/application.properties b/apollo-common/src/main/resources/application.properties index 34a37edb408..91f8ffcf837 100644 --- a/apollo-common/src/main/resources/application.properties +++ b/apollo-common/src/main/resources/application.properties @@ -19,5 +19,3 @@ logging.file.max-size=50MB logging.file.max-history=10 management.endpoints.web.exposure.include=info,health,metrics,prometheus -management.endpoint.metrics.enabled=true -management.endpoint.prometheus.enabled=true