Medium java backend

What is monitoring and observability, and how do Prometheus and Grafana fit?

The 30 second answer

Monitoring is how I watch defined signals and alert when they leave a budget. Observability is the broader ability to explain a new failure from the data the system emits: metrics, logs and traces, joined by ids. Prometheus is a pull-based metrics server with a time-series store and PromQL; applications expose a /metrics scrape endpoint. Grafana is the dashboard and alerting front end that can query Prometheus and other sources. Neither replaces structured logs or distributed traces.

Could you say this in an interview?

I keep the words distinct. Monitoring is "did a known condition happen?" Observability is "can I ask a question I did not anticipate?" Production systems need both.

Prometheus scrapes HTTP endpoints that speak the Prometheus text exposition format, stores time series, and evaluates alerting rules. The official concepts page describes the pull model, labels, and PromQL. For Java, the usual path is Micrometer plus the Prometheus registry, which Spring Boot Actuator can expose at /actuator/prometheus.

Grafana is not a metrics store. It queries Prometheus (and Loki, Tempo, and others), draws dashboards, and can send alerts. I version dashboard JSON or use Grafana's provisioning, rather than clicking a one-off graph that nobody owns.

Traces and logs stay in their own systems (Tempo/Jaeger, Loki/ELK). I put trace_id on log lines and job / route labels on metrics so a page in Grafana can jump to a trace.

# prometheus.yml sketch
scrape_configs:
  - job_name: checkout
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: ["checkout:8080"]
# PromQL: request rate and p99 latency (histogram quantile)
sum(rate(http_server_requests_seconds_count{job="checkout"}[5m]))
histogram_quantile(0.99, sum by (le) (rate(http_server_requests_seconds_bucket{job="checkout"}[5m])))
Sources (5)
  1. Prometheus: Data model and conceptsprometheus.io
  2. Prometheus: Getting startedprometheus.io
  3. Grafana documentationgrafana.com
  4. Spring Boot Actuator: Prometheus endpointdocs.spring.io
  5. Micrometer: Prometheusdocs.micrometer.io