Skip to content

Commit

Permalink
Merge pull request #271 from techeer-sv/BE/#269
Browse files Browse the repository at this point in the history
Be/#269 Prometheus + Grafana 연동
  • Loading branch information
baekhangyeol committed Nov 5, 2023
2 parents 78efb68 + c81710e commit 6d0c621
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ dependencies {
// Redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE'

// Prometheus
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

// LocalDataTime 역직렬화 문제 해결 패키지
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'com.fasterxml.jackson.core:jackson-databind'


}

tasks.named('test') {
Expand Down
16 changes: 16 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ spring:
logging:
config: classpath:logback-spring.xml

# Prometheus
management:
endpoints:
web:
exposure:
include: health, info, metrics, prometheus
metrics:
export:
prometheus:
enabled: true
endpoint:
prometheus:
enabled: true
info:
git:
mode: full

# swaggerDOC
springdoc:
Expand Down
9 changes: 9 additions & 0 deletions datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

datasource:
- name: Prometheus
type: prometheus
editable: true
is_default: true
access: proxy
url: http://prometheus:9090
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,27 @@ services:
ports:
- "3000:3000"

prometheus:
container_name: prometheus
image: prom/prometheus
ports:
- 9090:9090
volumes:
- ./prometheus:/etc/prometheus
- ./prometheus/data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
depends_on:
- springboot

grafana:
container_name: grafana
image: grafana/grafana
ports:
- 3001:3000
volumes:
- ./grafana:/var/lib/grafana
- ./datasource.yml:/etc/grafana/provisioning/datasource.yml
depends_on:
- prometheus
- springboot
16 changes: 16 additions & 0 deletions prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
global:
scrape_interval: 1s
evaluation_interval: 1s

alerting:
alertmanagers:
- static_configs:
- targets:

rule_files:

scrape_configs:
- job_name: "prometheus"
metrics_path: "/actuator/prometheus"
static_configs:
- targets: ["springboot:8080"]

0 comments on commit 6d0c621

Please sign in to comment.