From 14af0977175e9936b471a03ae2b5c0ab545f72e9 Mon Sep 17 00:00:00 2001 From: thguss Date: Fri, 6 Sep 2024 16:24:09 +0900 Subject: [PATCH] init: init monitoring system based local --- docker/monitoring/docker-compose.yml | 26 +++++++++++++++++++ docker/monitoring/prometheus.yml | 8 ++++++ smeem-bootstrap/build.gradle | 1 + .../main/resources/application-actuator.yml | 5 ++++ .../src/main/resources/application.yml | 8 ++++++ .../com/smeem/http/config/SecurityConfig.java | 1 + 6 files changed, 49 insertions(+) create mode 100644 docker/monitoring/docker-compose.yml create mode 100644 docker/monitoring/prometheus.yml create mode 100644 smeem-bootstrap/src/main/resources/application-actuator.yml create mode 100644 smeem-bootstrap/src/main/resources/application.yml 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 2e69f09d..7b89d620 100644 --- a/smeem-bootstrap/build.gradle +++ b/smeem-bootstrap/build.gradle @@ -12,6 +12,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 new file mode 100644 index 00000000..29c72846 --- /dev/null +++ b/smeem-bootstrap/src/main/resources/application.yml @@ -0,0 +1,8 @@ +spring: + config: + import: + - classpath:application-actuator.yml + application: + name: "smeem" + messages: + encoding: UTF-8 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); }