Monitoring Tools
Metrics alone are not a monitoring stack.
Introduction
Metrics alone are not a monitoring stack. For TechLearningPRO Orders on Spring Boot 3 / Java 21, the practical toolkit is Micrometer + Actuator emitting to Prometheus, visualized in Grafana, with logs in Loki (or a SaaS equivalent) and traces in Tempo / OpenTelemetry. SaaS stacks (Datadog, New Relic, Honeycomb) replace the same pillars with one agent.
Choose tools by the four golden signals: latency, traffic, errors, and saturation. Orders needs endpoint histograms, RPS, 5xx rate, Hikari wait, JVM heap, and GC — not fifty vanity gauges.
Self-hosted vs SaaS is a cost and ops trade-off; the Micrometer API stays the same. What changes is scrape vs push, retention, and who owns the pager.
This lesson maps the tool landscape so later production lessons wire alerts on user-visible symptoms, not noisy infra noise.
Purpose of this lesson
Select and place Prometheus/Grafana (or SaaS) tools around Orders so golden-signal dashboards and alerts are ready before scaling work.
Understanding the topic
One observability pipeline, four golden signals, tool choice second.
- Latency: p50/p95/p99 per Orders endpoint (Micrometer timers).
- Traffic: RPS and top paths — Prometheus counters / rate().
- Errors: 5xx and domain failure counters, not only HTTP status.
- Saturation: CPU, heap, GC, DB pool, queue depth.
- Stacks: Prometheus+Grafana+Loki+Tempo, or Datadog/New Relic/Honeycomb.
Step-by-step explanation
- Confirm Actuator exposes
prometheus(or your SaaS Micrometer registry). - Scrape Orders with Prometheus or install the SaaS agent; tag
application=orders. - Build one Grafana (or SaaS) overview: latency, RPS, errors, Hikari active/pending.
- Add an alert on checkout p99 or 5xx burn — not on disk % of a healthy node.
Informative example
Prometheus scrape + a Grafana-ready business timer on Orders.
# prometheus.yml (excerpt)scrape_configs:- job_name: ordersmetrics_path: /actuator/prometheusstatic_configs:- targets: ["orders:8081"]labels:application: ordersenv: prod// OrderService — Micrometer timer (Boot 3)@Servicepublic class OrderService {private final Timer placeTimer;private final OrderRepository orders;public OrderService(MeterRegistry registry, OrderRepository orders) {this.placeTimer = Timer.builder("orders.place").publishPercentiles(0.5, 0.95, 0.99).register(registry);this.orders = orders;}public OrderView place(CreateOrderRequest cmd) {return placeTimer.record(() -> OrderView.from(orders.save(OrderEntity.from(cmd))));}}
Real-world use
TechLearningPRO once had twelve Grafana panels of JVM trivia and no checkout latency chart. During a Black Friday spike, on-call could not see whether Orders or Inventory was slow. Replacing vanity dashboards with golden-signal panels plus a single orders.place timer cut MTTR from hours to minutes.
Security implications
Monitoring endpoints and agents are privileged surfaces.
- Network-restrict or authenticate non-health Actuator endpoints.
- Never ship real credentials in scrape configs — use placeholders like
${PROM_TOKEN}. - Redact PII from log-derived metrics and trace attributes.
Best practices
- Dashboards per service plus one executive overview page.
- Alert on user-visible symptoms (latency, errors) with runbook links.
- Keep Micrometer tags low-cardinality (tier, region, outcome).
Common mistakes
- Alerting on CPU alone while p99 checkout is already failing SLOs.
- High-cardinality labels (raw orderId) exploding Prometheus series.
- Leaving Actuator
heapdump/envexposed on the public port.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat are the four golden signals?+
Answer
2IntermediateQuestionWhy prefer Micrometer over a vendor-specific metrics API in Boot 3?+
Answer
3IntermediateQuestionWhen is SaaS better than self-hosted Prometheus?+
Answer
Hands-on exercise
Lab. Enable Micrometer Prometheus registry on Orders. Scrape /actuator/prometheus, graph orders_place percentiles in Grafana (or your SaaS UI), and write one alert rule for p99 above your SLO.
Summary
Monitoring tools turn Orders into an operable Boot 3 service. Next: use those signals to decide how and when to scale the backend.