#25 spring cloud: prometheus + grafana
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
0
springcloud/prometheus.yml
Normal file
0
springcloud/prometheus.yml
Normal 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'
|
||||
|
||||
@@ -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() ;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user