mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-25 16:22:35 +03:00
expose prometheus metrics, add health endpoint
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
4
doc/examples/management/health.md
Normal file
4
doc/examples/management/health.md
Normal file
@@ -0,0 +1,4 @@
|
||||
```shell
|
||||
curl --request GET \
|
||||
--url 'http://localhost:8080/health'
|
||||
```
|
||||
18
doc/examples/management/metrics.md
Normal file
18
doc/examples/management/metrics.md
Normal file
@@ -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/<metric-name>'
|
||||
```
|
||||
@@ -32,4 +32,24 @@ springdoc:
|
||||
api-docs:
|
||||
path: /doc/openapi
|
||||
swagger-ui:
|
||||
path: /doc/swagger-ui.html
|
||||
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
|
||||
Reference in New Issue
Block a user