#25 spring cloud: prometheus + grafana

This commit is contained in:
haerong22
2022-12-31 18:49:51 +09:00
parent a445ff6bbe
commit 490427b42f
8 changed files with 32 additions and 4 deletions

View File

@@ -31,6 +31,10 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
implementation 'org.springframework.cloud:spring-cloud-starter-bus-amqp'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.netty:netty-resolver-dns-native-macos:4.1.86.Final:osx-aarch_64'
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
implementation group: 'javax.xml.bind', name: 'jaxb-api'

View File

@@ -7,6 +7,8 @@ eureka:
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka
instance:
hostname: localhost
spring:
application:
@@ -27,6 +29,15 @@ spring:
preLogger: true
postLogger: true
routes:
- id: order-service
uri: lb://ORDER-SERVICE
predicates:
- Path=/order-service/actuator/**
- Method=GET, POST
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/order-service/(?<segment>.*), /$\{segment}
- id: order-service
uri: lb://ORDER-SERVICE
predicates:
@@ -70,7 +81,6 @@ spring:
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/user-service/(?<segment>.*), /$\{segment}
- id: first-service
uri: lb://MY-FIRST-SERVICE
predicates:
@@ -101,4 +111,4 @@ management:
endpoints:
web:
exposure:
include: refresh, health, beans, httptrace, busrefresh
include: refresh, health, beans, httptrace, busrefresh, info, metrics, prometheus

View File

@@ -27,6 +27,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.mariadb.jdbc:mariadb-java-client'

View File

@@ -44,4 +44,10 @@ eureka:
logging:
level:
com.example.orderservice: debug
com.example.orderservice: debug
management:
endpoints:
web:
exposure:
include: refresh, health, beans, busrefresh, info, metrics, prometheus

View File

View File

@@ -37,6 +37,8 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'org.springframework.cloud:spring-cloud-starter-zipkin:2.2.3.RELEASE'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.4.4'

View File

@@ -6,6 +6,7 @@ import com.example.userservice.service.UserService;
import com.example.userservice.vo.Greeting;
import com.example.userservice.vo.RequestUser;
import com.example.userservice.vo.ResponseUser;
import io.micrometer.core.annotation.Timed;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
@@ -32,6 +33,7 @@ public class UserController {
@GetMapping("/health_check")
@Timed(value = "users.status", longTask = true)
public String status() {
return "It's working in User Service"
+ ", port(local.server.port)=" + env.getProperty("local.server.port")
@@ -41,6 +43,7 @@ public class UserController {
}
@GetMapping("/welcome")
@Timed(value = "users.welcome", longTask = true)
public String welcome() {
return greeting.getMessage() ;
}

View File

@@ -49,7 +49,7 @@ management:
endpoints:
web:
exposure:
include: refresh, health, beans, busrefresh
include: refresh, health, beans, busrefresh, info, metrics, prometheus
#token:
# expiration_time: 86400000