File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
java/io/f1/backend/global/config Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,22 @@ repositories {
2424}
2525
2626dependencies {
27+ /* SPRING BOOT STARTER */
2728 implementation ' org.springframework.boot:spring-boot-starter-validation'
2829 implementation ' org.springframework.boot:spring-boot-starter-web'
2930 implementation ' org.springframework.boot:spring-boot-starter-data-jpa'
3031 implementation ' org.springframework.boot:spring-boot-starter-data-redis'
3132 implementation ' org.springframework.boot:spring-boot-starter-websocket'
3233 implementation ' org.springframework.boot:spring-boot-starter-security'
3334 implementation ' org.springframework.boot:spring-boot-starter-oauth2-client'
35+ implementation ' org.springframework.boot:spring-boot-starter-actuator'
3436
3537 /* DATABASE */
3638 runtimeOnly ' com.mysql:mysql-connector-j'
3739
40+ /* MONITORING */
41+ implementation ' io.micrometer:micrometer-registry-prometheus'
42+
3843 /* TEST */
3944 testImplementation ' org.springframework.boot:spring-boot-starter-test'
4045 testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
Original file line number Diff line number Diff line change 1010
1111import lombok .RequiredArgsConstructor ;
1212
13+ import org .springframework .beans .factory .annotation .Value ;
1314import org .springframework .context .annotation .Bean ;
1415import org .springframework .context .annotation .Configuration ;
1516import org .springframework .http .HttpMethod ;
@@ -32,6 +33,9 @@ public class SecurityConfig {
3233 private final AdminLoginSuccessHandler adminLoginSuccessHandler ;
3334 private final AdminLoginFailureHandler adminLoginFailureHandler ;
3435
36+ @ Value ("${management.endpoints.web.base-path:/actuator}" )
37+ private String actuatorBasePath ;
38+
3539 @ Bean
3640 public SecurityFilterChain userFilterChain (HttpSecurity http ) throws Exception {
3741 http .csrf (AbstractHttpConfigurer ::disable )
@@ -66,6 +70,8 @@ public SecurityFilterChain userFilterChain(HttpSecurity http) throws Exception {
6670 .hasAnyRole ("USER" , "ADMIN" )
6771 .requestMatchers ("/questions/**" )
6872 .hasAnyRole ("USER" , "ADMIN" )
73+ .requestMatchers (actuatorBasePath + "/**" )
74+ .hasRole ("PROMETHEUS" )
6975 .anyRequest ()
7076 .authenticated ())
7177 .formLogin (
Original file line number Diff line number Diff line change @@ -64,4 +64,26 @@ server:
6464 secure : true
6565 http-only : true
6666 timeout : ${SESSION_TIMEOUT}
67+ ---
68+ spring :
69+ config :
70+ activate :
71+ on-profile : prod
72+
73+ security :
74+ user :
75+ name : ${PROM_NAME}
76+ password : ${PROM_PASSWORD}
77+ roles : PROMETHEUS
6778
79+ management :
80+ server :
81+ port : ${ACTUATOR_PORT}
82+ endpoints :
83+ web :
84+ exposure :
85+ include : " prometheus"
86+ base-path : ${ACTUATOR_BASE_PATH}
87+ endpoint :
88+ prometheus :
89+ access : read_only
You can’t perform that action at this time.
0 commit comments