diff --git a/build.gradle.kts b/build.gradle.kts index f58ad8c..32f129f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,6 +41,8 @@ dependencies { testImplementation("io.github.bonigarcia:selenium-jupiter:$seleniumJupiterVersion") testImplementation("io.github.bonigarcia:webdrivermanager:$webdrivermanagerVersion") testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion") + runtimeOnly("io.micrometer:micrometer-registry-prometheus:1.12.5") + implementation("org.springframework.boot:spring-boot-starter-actuator:3.2.5") } tasks.register("unitTest") { diff --git a/monitoring/docker-compose.yml b/monitoring/docker-compose.yml new file mode 100644 index 0000000..654ee2e --- /dev/null +++ b/monitoring/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3.7' + +services: + prometheus: + image: prom/prometheus:v2.44.0 + container_name: prometheus + ports: + - "9090:9090" + volumes: + - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml + + grafana: + image: grafana/grafana:9.5.2 + container_name: grafana + ports: + - "3000:3000" + restart: unless-stopped + volumes: + - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources \ No newline at end of file diff --git a/monitoring/grafana/provisioning/datasources/datasources.yml b/monitoring/grafana/provisioning/datasources/datasources.yml new file mode 100644 index 0000000..8d9f9d8 --- /dev/null +++ b/monitoring/grafana/provisioning/datasources/datasources.yml @@ -0,0 +1,7 @@ +apiVersion: 1 +datasources: + - name: Prometheus + type: prometheus + access: proxy + url: http://prometheus:9090 + isDefault: true \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.yml b/monitoring/prometheus/prometheus.yml new file mode 100644 index 0000000..8f5dfb2 --- /dev/null +++ b/monitoring/prometheus/prometheus.yml @@ -0,0 +1,8 @@ +scrape_configs: + - job_name: 'MyAppMetrics' + metrics_path: '/actuator/prometheus' + scrape_interval: 3s + static_configs: + - targets: ['host.docker.internal:8080'] + labels: + application: 'subscription' \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cac1712..0bc5585 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,3 @@ spring.application.name=subscription-admin -spring.profiles.active=${PRODUCTION:prod} \ No newline at end of file +spring.profiles.active=${PRODUCTION:dev} +management.endpoints.web.exposure.include=* \ No newline at end of file