Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add prometheus integration. #2507

Merged
merged 5 commits into from
Aug 12, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apollo-common/pom.xml
Original file line number Diff line number Diff line change
@@ -60,5 +60,20 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>

<!-- Spring boot actuator to expose metrics endpoint -->
<dependency>
JaredTan95 marked this conversation as resolved.
Show resolved Hide resolved
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Micormeter core dependecy -->
JaredTan95 marked this conversation as resolved.
Show resolved Hide resolved
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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<TomcatServletWebServerFactory> {

@@ -29,7 +27,6 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentRes
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON_UTF8);
}

@Override
4 changes: 4 additions & 0 deletions apollo-common/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -17,3 +17,7 @@ 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=info,health,metrics,prometheus
management.endpoint.metrics.enabled=true
JaredTan95 marked this conversation as resolved.
Show resolved Hide resolved
management.endpoint.prometheus.enabled=true
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 1 addition & 1 deletion apollo-portal/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -22,6 +22,6 @@ logging:
management:
health:
status:
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP