diff --git a/docker/monitoring/docker-compose.yml b/docker/monitoring/docker-compose.yml new file mode 100644 index 00000000..635b8d4c --- /dev/null +++ b/docker/monitoring/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.8' + +services: + prometheus: + image: prom/prometheus:latest + container_name: prometheus + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + command: + - --config.file=/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + networks: + - monitoring-network + + grafana: + image: grafana/grafana:latest + container_name: grafana + ports: + - "3000:3000" + networks: + - monitoring-network + +networks: + monitoring-network: + driver: bridge diff --git a/docker/monitoring/prometheus.yml b/docker/monitoring/prometheus.yml new file mode 100644 index 00000000..9f83897b --- /dev/null +++ b/docker/monitoring/prometheus.yml @@ -0,0 +1,8 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: prometheus + metrics_path: '/actuator/prometheus' + static_configs: + - targets: ['host.docker.internal:8080'] diff --git a/smeem-bootstrap/build.gradle b/smeem-bootstrap/build.gradle index 14c6ab5e..ffde381a 100644 --- a/smeem-bootstrap/build.gradle +++ b/smeem-bootstrap/build.gradle @@ -14,6 +14,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-actuator' + runtimeOnly 'io.micrometer:micrometer-registry-prometheus' } tasks.bootJar { diff --git a/smeem-bootstrap/src/main/resources/application-actuator.yml b/smeem-bootstrap/src/main/resources/application-actuator.yml new file mode 100644 index 00000000..264baaf1 --- /dev/null +++ b/smeem-bootstrap/src/main/resources/application-actuator.yml @@ -0,0 +1,5 @@ +management: + endpoints: + web: + exposure: + include: info, health, metrics, prometheus diff --git a/smeem-bootstrap/src/main/resources/application.yml b/smeem-bootstrap/src/main/resources/application.yml index 3d60f036..401984da 100644 --- a/smeem-bootstrap/src/main/resources/application.yml +++ b/smeem-bootstrap/src/main/resources/application.yml @@ -1,6 +1,7 @@ spring: config: import: + - classpath:application-actuator.yml - classpath:oauth-apple-config/application.yml - classpath:oauth-kakao-config/application.yml application: diff --git a/smeem-input-http/src/main/java/com/smeem/http/config/SecurityConfig.java b/smeem-input-http/src/main/java/com/smeem/http/config/SecurityConfig.java index 3a5b37a0..2326b041 100644 --- a/smeem-input-http/src/main/java/com/smeem/http/config/SecurityConfig.java +++ b/smeem-input-http/src/main/java/com/smeem/http/config/SecurityConfig.java @@ -56,6 +56,7 @@ private void setHttp(HttpSecurity http) throws Exception { .requestMatchers(new AntPathRequestMatcher("/api/v2/plans")).permitAll() .requestMatchers(new AntPathRequestMatcher("/favicon.ico")).permitAll() .requestMatchers(new AntPathRequestMatcher("/error")).permitAll() + .requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() .anyRequest().authenticated()) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); }