This episode covers observability and production support: JVM metrics and metric collection with Micrometer, log management and structured logging, distributed tracing with OpenTelemetry and Grafana, health checks and readiness probes, plus incident response and SLOs.

Applications in production need eyes that can see inside. Episode 22 covers monitoring, observability, and production support: JVM metrics with Micrometer, log management and structured logging, distributed tracing with OpenTelemetry, plus health checks, readiness probes, incident response, and SLOs.
Observability answers three questions: what is happening, why is it happening, and how do we fix it. You will build a system that makes applications observable and well-managed in production.
Metrics are measurable numbers about application behavior: CPU, memory, heap, thread count, and GC pauses. Metrics give a picture of application health over time.
Micrometer provides a unified metrics API that can be exported to various backends (Prometheus, Datadog, Grafana Cloud). Add the dependency:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.13.3</version>
</dependency>Create a simple counter and timer:
import io.micrometer.core.instrument.*;
public class MetrikApp {
private final Counter requestCounter;
public MetrikApp(MeterRegistry registry) {
this.requestCounter = Counter.builder("app.request.total")
.description("Total request masuk")
.register(registry);
}
public void handleRequest() {
requestCounter.increment();
}
}Counter.builder("app.request.total") registers a metric that increments with every request.
Structured logging writes logs in a structured format (JSON) so they are easy to search and analyze. With SLF4J and Logback, the JSON output includes fields such as timestamp, level, and message:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Layanan {
private static final Logger log = LoggerFactory.getLogger(Layanan.class);
public void proses(String id) {
log.info("Memproses pesanan dengan id {}", id);
}
}log.info("Memproses pesanan dengan id {}", id) uses parameterized logging — avoid string concatenation.
Collect logs from many services into one place: the ELK Stack (Elasticsearch, Logstash, Kibana) or Loki + Grafana. Consolidating logs makes cross-service troubleshooting possible.
In microservices, a single request crosses many services. Distributed tracing tracks that request journey with traceId and spanId, so you can see where time is spent.
OpenTelemetry is the open source observability standard. Add the agent without changing application code:
java -javaagent:opentelemetry-javaagent.jar \
-Dotel.service.name=aplikasi-demo \
-jar aplikasi.jar-javaagent:opentelemetry-javaagent.jar instruments the application automatically, sending traces to a backend such as Grafana Tempo or Jaeger.
A health check tells the orchestrator whether the application is healthy. With Spring Boot Actuator:
curl http://localhost:8080/actuator/healthcurl http://localhost:8080/actuator/health returns a status of UP or DOWN.
In Kubernetes, two distinct probes:
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080Incident response is the structured process when a problem occurs: detection, triage, mitigation (rollback), communication, and post-mortem. Documented runbooks speed up recovery and reduce panic.
An SLO (Service Level Objective) sets a health target, for example 99.9% availability. Good alerts notify the team before the SLO is threatened, not after. Micrometer metrics and Prometheus alert rules are the basis for this:
error rate < 0.1% -> alert saat mendekati ambangEpisode 22 covers observability and production support: JVM metrics with Micrometer, log management and structured logging, distributed tracing with OpenTelemetry and Grafana, health checks, readiness probes, incident response, and SLOs.
Key takeaways:
In the next episode, episode 23, the final episode of this series, we will discuss future-proof Java and ecosystem trends — stable modern features in Java 21, Project Loom and virtual threads, Project Amber and pattern matching, Project Panama and the foreign function interface, plus strategies to keep your Java skills relevant. See you in the final episode!