diff --git a/build.gradle.kts b/build.gradle.kts index 1d5ea89..822c5b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("org.springframework.boot") version "3.2.4" - id("io.spring.dependency-management") version "1.1.4" + id("org.springframework.boot") version "3.2.10" + id("io.spring.dependency-management") version "1.1.6" jacoco @@ -22,7 +22,7 @@ repositories { } dependencies { - api("org.springframework.boot:spring-boot-starter-data-jdbc:3.2.4") + api("org.springframework.boot:spring-boot-starter-data-jdbc:3.2.10") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.4") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.4") @@ -32,16 +32,19 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") implementation("org.postgresql:postgresql:42.6.2") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0") - implementation("org.springframework.boot:spring-boot-starter-mustache:3.2.4") - implementation("org.springframework.boot:spring-boot-starter-validation:3.2.4") - implementation("org.springframework.boot:spring-boot-starter-web:3.2.4") + implementation("org.springframework.boot:spring-boot-starter-actuator:3.2.10") + implementation("org.springframework.boot:spring-boot-starter-mustache:3.2.10") + implementation("org.springframework.boot:spring-boot-starter-validation:3.2.10") + implementation("org.springframework.boot:spring-boot-starter-web:3.2.10") implementation("org.springframework.kafka:spring-kafka:3.1.3") + runtimeOnly("io.micrometer:micrometer-registry-prometheus") + developmentOnly("org.springframework.boot:spring-boot-devtools") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:2.0.20") testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") - testImplementation("org.springframework.boot:spring-boot-starter-test:3.2.4") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.2.10") testImplementation("org.springframework.kafka:spring-kafka-test:3.1.3") testImplementation("org.testcontainers:junit-jupiter:1.19.7") testImplementation("org.testcontainers:testcontainers:1.19.7") diff --git a/checklist.md b/checklist.md index 1990758..2da90a8 100644 --- a/checklist.md +++ b/checklist.md @@ -3,9 +3,9 @@ Some simple checklist for this demo repo: - [x] make migrations - [x] make repository and models - [x] make crud api -- [ ] make openapi documentation generation +- [x] make openapi documentation generation - [x] connect to kafka to produce events - [x] make kafka consumer - [ ] register prometheus metrics -- [ ] expose prometheus metrics +- [x] expose prometheus metrics - [ ] add otel collector diff --git a/doc/examples/management/health.md b/doc/examples/management/health.md new file mode 100644 index 0000000..f551237 --- /dev/null +++ b/doc/examples/management/health.md @@ -0,0 +1,4 @@ +```shell +curl --request GET \ + --url 'http://localhost:8080/health' +``` \ No newline at end of file diff --git a/doc/examples/management/metrics.md b/doc/examples/management/metrics.md new file mode 100644 index 0000000..4509c11 --- /dev/null +++ b/doc/examples/management/metrics.md @@ -0,0 +1,18 @@ +Метрики приложения в формате prometheus: + +```shell +curl --request GET \ + --url 'http://localhost:8081/metrics' +``` + +Список доступных для отображения метрик приложения: +```shell +curl --request GET \ + --url 'http://localhost:8081/spring-metrics' +``` + +Значение конкретной метрики: +```shell +curl --request GET \ + --url 'http://localhost:8081/spring-metrics/' +``` diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0d008c6..1566f1f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -32,4 +32,24 @@ springdoc: api-docs: path: /doc/openapi swagger-ui: - path: /doc/swagger-ui.html \ No newline at end of file + path: /doc/swagger-ui.html + +management: + server: + port: 8081 + endpoints: + web: + base-path: / + path-mapping: + metrics: spring-metrics + prometheus: metrics + info: version + exposure: + include: health,prometheus,info,metrics + endpoint: + health: + show-details: always + metrics: + distribution: + percentiles-histogram: + "[http.server.requests]": true \ No newline at end of file