Skip to content

Commit

Permalink
Merge pull request #2 from BE-04-JTOON/feat/monitoring
Browse files Browse the repository at this point in the history
feat: 모니터링 추가
  • Loading branch information
parksey authored Apr 17, 2024
2 parents 7b543ba + 8570f59 commit 4c0b205
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ smtp.yml
redis.yml
db-main.yml
logging.yml

volume
query_log_file.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package shop.jtoon.global.presentation;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HealthCheckController {

@GetMapping("/health")
public ResponseEntity<Object> health() {
return ResponseEntity.status(HttpStatus.OK).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public WebSecurityCustomizer webSecurityCustomizer() {
.requestMatchers("/members/sign-up")
.requestMatchers("/members/email-authorization")
.requestMatchers("/members/local-login")
.requestMatchers("/")
.requestMatchers("/actuator/prometheus")
;
}

Expand Down
4 changes: 4 additions & 0 deletions jtoon-support/monitoring/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
}
40 changes: 40 additions & 0 deletions jtoon-support/monitoring/infra/prom-grafana/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.7'
services:
prometheus:
image: prom/prometheus
container_name: prometheus
volumes:
- ./prometheus/config:/etc/prometheus
- ./prometheus/volume:/prometheus
ports:
- 9090:9090
command:
- '--web.enable-lifecycle'
- '--config.file=/etc/prometheus/prometheus.yml'
restart: always
networks:
- promnet

grafana:
image: grafana/grafana
container_name: grafana
ports:
- 3000:3000
volumes:
- ./grafana/volume:/var/lib/grafana
restart: always
networks:
- promnet

node-exporter:
container_name: node-exporter
image: prom/node-exporter
ports:
- 9100:9100
restart: always
networks:
- promnet

networks:
promnet:
driver: bridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
global:
scrape_interval: 10s
scrape_timeout: 10s
query_log_file: query_log_file.log

alerting:
alertmanagers:
- static_configs:
- targets:

scrape_configs:
- job_name: 'prometheus'
metrics_path: '/actuator/prometheus'
scheme: 'http'
static_configs:
- targets: ['host.docker.internal:8080']
labels:
service: 'server-monitor1'

- job_name: 'exporter'
metrics_path: '/metrics'
scheme: 'http'
static_configs:
- targets: [ 'host.docker.internal:9100' ]
labels:
service: 'system-monitor1'
5 changes: 5 additions & 0 deletions jtoon-support/monitoring/src/main/resources/monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
management:
endpoints:
web:
exposure:
include: health, prometheus

0 comments on commit 4c0b205

Please sign in to comment.