0
# Observability and Monitoring
1
2
Metrics, tracing, and monitoring libraries with Micrometer integration. These libraries provide comprehensive observability capabilities for production applications including metrics collection, distributed tracing, and health monitoring.
3
4
## Capabilities
5
6
### Metrics Collection
7
8
Core metrics collection and registry implementations with Micrometer integration.
9
10
```gradle { .api }
11
// Micrometer core
12
'io.micrometer:micrometer-core' // 1.15.1
13
'io.micrometer:micrometer-observation' // 1.15.1
14
15
// Common registries
16
'io.micrometer:micrometer-registry-prometheus' // 1.15.1
17
'io.micrometer:micrometer-registry-jmx' // 1.15.1
18
'io.micrometer:micrometer-registry-graphite' // 1.15.1
19
20
// Cloud provider registries
21
'io.micrometer:micrometer-registry-cloudwatch' // 1.15.1
22
'io.micrometer:micrometer-registry-cloudwatch2' // 1.15.1
23
'io.micrometer:micrometer-registry-datadog' // 1.15.1
24
'io.micrometer:micrometer-registry-new-relic' // 1.15.1
25
'io.micrometer:micrometer-registry-stackdriver' // 1.15.1
26
27
// Time series databases
28
'io.micrometer:micrometer-registry-influx' // 1.15.1
29
'io.micrometer:micrometer-registry-wavefront' // 1.15.1
30
'io.micrometer:micrometer-registry-elastic' // 1.15.1
31
32
// Application Performance Monitoring
33
'io.micrometer:micrometer-registry-appoptics' // 1.15.1
34
'io.micrometer:micrometer-registry-dynatrace' // 1.15.1
35
'io.micrometer:micrometer-registry-signalfx' // 1.15.1
36
```
37
38
### Distributed Tracing
39
40
Distributed tracing implementations and bridges for microservice observability.
41
42
```gradle { .api }
43
// Micrometer Tracing core
44
'io.micrometer:micrometer-tracing' // 1.5.1
45
46
// Brave (Zipkin) integration
47
'io.micrometer:micrometer-tracing-bridge-brave' // 1.5.1
48
'io.zipkin.brave:brave' // 6.1.0
49
'io.zipkin.brave:brave-instrumentation-http' // 6.1.0
50
'io.zipkin.brave:brave-instrumentation-spring-web' // 6.1.0
51
'io.zipkin.brave:brave-instrumentation-spring-webmvc' // 6.1.0
52
53
// OpenTelemetry integration
54
'io.micrometer:micrometer-tracing-bridge-otel' // 1.5.1
55
'io.opentelemetry:opentelemetry-api' // 1.49.0
56
'io.opentelemetry:opentelemetry-sdk' // 1.49.0
57
'io.opentelemetry:opentelemetry-exporter-zipkin' // 1.49.0
58
'io.opentelemetry:opentelemetry-exporter-jaeger' // 1.49.0
59
60
// Zipkin reporting
61
'io.zipkin.reporter2:zipkin-reporter' // 3.5.1
62
'io.zipkin.reporter2:zipkin-sender-okhttp3' // 3.5.1
63
'io.zipkin.reporter2:zipkin-sender-kafka' // 3.5.1
64
```
65
66
### Prometheus Integration
67
68
Prometheus metrics exposition and client libraries.
69
70
```gradle { .api }
71
// Prometheus client (new metrics)
72
'io.prometheus:prometheus-metrics-core' // 1.3.8
73
'io.prometheus:prometheus-metrics-exposition-formats' // 1.3.8
74
'io.prometheus:prometheus-metrics-instrumentation-jvm' // 1.3.8
75
'io.prometheus:prometheus-metrics-exporter-httpserver' // 1.3.8
76
'io.prometheus:prometheus-metrics-exporter-servlet-jakarta' // 1.3.8
77
78
// Prometheus client (legacy simpleclient)
79
'io.prometheus:simpleclient' // 0.16.0
80
'io.prometheus:simpleclient_httpserver' // 0.16.0
81
'io.prometheus:simpleclient_servlet_jakarta' // 0.16.0
82
'io.prometheus:simpleclient_pushgateway' // 0.16.0
83
```
84
85
### Health Monitoring
86
87
Application health and liveness monitoring with Spring Boot Actuator.
88
89
```gradle { .api }
90
// Spring Boot Actuator
91
'org.springframework.boot:spring-boot-starter-actuator' // 3.5.3
92
'org.springframework.boot:spring-boot-actuator' // 3.5.3
93
'org.springframework.boot:spring-boot-actuator-autoconfigure' // 3.5.3
94
```
95
96
### Logging and Structured Output
97
98
Logging frameworks with structured output and correlation support.
99
100
```gradle { .api }
101
// SLF4J (logging facade)
102
'org.slf4j:slf4j-api' // 2.0.17
103
104
// Logback (default Spring Boot logging)
105
'ch.qos.logback:logback-classic' // 1.5.18
106
'ch.qos.logback:logback-core' // 1.5.18
107
108
// Log4j2 alternative
109
'org.apache.logging.log4j:log4j-core' // 2.24.3
110
'org.apache.logging.log4j:log4j-slf4j2-impl' // 2.24.3
111
'org.apache.logging.log4j:log4j-layout-template-json' // 2.24.3
112
113
// Logging bridges
114
'org.slf4j:jul-to-slf4j' // 2.0.17
115
'org.slf4j:log4j-over-slf4j' // 2.0.17
116
'org.slf4j:jcl-over-slf4j' // 2.0.17
117
118
// JBoss Logging (used by Hibernate)
119
'org.jboss.logging:jboss-logging' // 3.6.1.Final
120
```
121
122
### Application Performance Monitoring
123
124
APM agent libraries and instrumentation.
125
126
```gradle { .api }
127
// Java agent instrumentation
128
'net.bytebuddy:byte-buddy' // 1.17.6
129
'net.bytebuddy:byte-buddy-agent' // 1.17.6
130
131
// Micrometer common utilities
132
'io.micrometer:micrometer-commons' // 1.15.1
133
```
134
135
## Usage Examples
136
137
### Basic Observability Setup
138
139
```gradle
140
dependencies {
141
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
142
143
implementation 'org.springframework.boot:spring-boot-starter-web'
144
implementation 'org.springframework.boot:spring-boot-starter-actuator'
145
implementation 'io.micrometer:micrometer-registry-prometheus'
146
147
testImplementation 'org.springframework.boot:spring-boot-starter-test'
148
}
149
```
150
151
### Distributed Tracing with Zipkin
152
153
```gradle
154
dependencies {
155
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
156
157
implementation 'org.springframework.boot:spring-boot-starter-web'
158
implementation 'org.springframework.boot:spring-boot-starter-actuator'
159
160
// Micrometer tracing with Brave/Zipkin
161
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
162
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
163
164
testImplementation 'org.springframework.boot:spring-boot-starter-test'
165
}
166
```
167
168
### OpenTelemetry Integration
169
170
```gradle
171
dependencies {
172
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
173
174
implementation 'org.springframework.boot:spring-boot-starter-web'
175
implementation 'org.springframework.boot:spring-boot-starter-actuator'
176
177
// OpenTelemetry tracing
178
implementation 'io.micrometer:micrometer-tracing-bridge-otel'
179
implementation 'io.opentelemetry:opentelemetry-exporter-zipkin'
180
181
testImplementation 'org.springframework.boot:spring-boot-starter-test'
182
}
183
```
184
185
### Multi-Registry Metrics
186
187
```gradle
188
dependencies {
189
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
190
191
implementation 'org.springframework.boot:spring-boot-starter-web'
192
implementation 'org.springframework.boot:spring-boot-starter-actuator'
193
194
// Multiple metrics registries
195
implementation 'io.micrometer:micrometer-registry-prometheus'
196
implementation 'io.micrometer:micrometer-registry-jmx'
197
implementation 'io.micrometer:micrometer-registry-cloudwatch'
198
199
testImplementation 'org.springframework.boot:spring-boot-starter-test'
200
}
201
```
202
203
### Custom Prometheus Metrics
204
205
```gradle
206
dependencies {
207
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
208
209
implementation 'org.springframework.boot:spring-boot-starter-web'
210
implementation 'org.springframework.boot:spring-boot-starter-actuator'
211
212
// Prometheus metrics with custom instrumentation
213
implementation 'io.micrometer:micrometer-registry-prometheus'
214
implementation 'io.prometheus:prometheus-metrics-core'
215
implementation 'io.prometheus:prometheus-metrics-instrumentation-jvm'
216
217
testImplementation 'org.springframework.boot:spring-boot-starter-test'
218
}
219
```
220
221
### Structured Logging with JSON
222
223
```gradle
224
dependencies {
225
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
226
227
implementation 'org.springframework.boot:spring-boot-starter-web'
228
implementation 'org.springframework.boot:spring-boot-starter-actuator'
229
230
// Switch to Log4j2 for JSON logging
231
implementation('org.springframework.boot:spring-boot-starter-log4j2') {
232
exclude module: 'spring-boot-starter-logging'
233
}
234
implementation 'org.apache.logging.log4j:log4j-layout-template-json'
235
236
testImplementation 'org.springframework.boot:spring-boot-starter-test'
237
}
238
```
239
240
### Complete Observability Stack
241
242
```gradle
243
dependencies {
244
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
245
246
implementation 'org.springframework.boot:spring-boot-starter-web'
247
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
248
implementation 'org.springframework.boot:spring-boot-starter-actuator'
249
250
// Metrics collection
251
implementation 'io.micrometer:micrometer-registry-prometheus'
252
implementation 'io.micrometer:micrometer-registry-jmx'
253
254
// Distributed tracing
255
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
256
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
257
258
// Custom metrics
259
implementation 'io.prometheus:prometheus-metrics-core'
260
261
runtimeOnly 'org.postgresql:postgresql'
262
263
testImplementation 'org.springframework.boot:spring-boot-starter-test'
264
testImplementation 'org.testcontainers:postgresql'
265
}
266
```
267
268
### Cloud-Native Observability
269
270
```gradle
271
dependencies {
272
implementation platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
273
274
implementation 'org.springframework.boot:spring-boot-starter-web'
275
implementation 'org.springframework.boot:spring-boot-starter-actuator'
276
277
// Cloud provider specific metrics
278
implementation 'io.micrometer:micrometer-registry-cloudwatch'
279
implementation 'io.micrometer:micrometer-registry-datadog'
280
281
// Distributed tracing for cloud
282
implementation 'io.micrometer:micrometer-tracing-bridge-otel'
283
implementation 'io.opentelemetry:opentelemetry-exporter-jaeger'
284
285
testImplementation 'org.springframework.boot:spring-boot-starter-test'
286
}
287
```
288
289
## Configuration Examples
290
291
### Prometheus Metrics Endpoint
292
293
```yaml
294
# application.yml
295
management:
296
endpoints:
297
web:
298
exposure:
299
include: health,info,metrics,prometheus
300
endpoint:
301
prometheus:
302
enabled: true
303
metrics:
304
export:
305
prometheus:
306
enabled: true
307
```
308
309
### Distributed Tracing Configuration
310
311
```yaml
312
# application.yml
313
management:
314
tracing:
315
sampling:
316
probability: 0.1
317
zipkin:
318
tracing:
319
endpoint: http://zipkin:9411/api/v2/spans
320
```
321
322
### Multi-Registry Configuration
323
324
```yaml
325
# application.yml
326
management:
327
metrics:
328
export:
329
prometheus:
330
enabled: true
331
jmx:
332
enabled: true
333
cloudwatch:
334
namespace: MyApplication
335
enabled: true
336
```