liveBook · Manning

Metric endpoint

As explained in Machine Learning Platform Engineering

A metrics endpoint is an HTTP endpoint that exposes an application's operational measurements for collection by a monitoring system.

A metric endpoint exposes an application's operational measurements over HTTP so Prometheus can collect them. A monitoring worker scrapes a path such as /metrics, stores the results as time series, and supports visualization and alerting through Grafana and Alertmanager. section 3.5

A production metric endpoint connects application instrumentation to the monitoring stack:

  • Expose standard measurements such as request counts, response times, latency, and response codes. section 3.5 section 6.1.3
  • Let Prometheus pull and store the endpoint output, then query it with PromQL. section 3.5
  • Visualize queried series in Grafana and route threshold-based alerts through Alertmanager. section 3.5
  • Configure Kubernetes discovery with scrape annotations that identify the path and port. section 3.5

FastAPI endpoint with Starlette Exporter

Add PrometheusMiddleware to collect basic application metrics, then register handle_metrics at /metrics. This exposes measurements without implementing the endpoint logic manually. section 3.5

Figure 3.17 Application 1 and Application 2 expose an endpoint for metrics. Prometheus scrapes those metrics, which are then visualized by Grafana. Alertmanager uses those metrics to check if any alerts need to be routed to a channel; in this case, it’s an email.
A diagram of a diagram

AI-generated content may be incorrect.

Trace the operational flow from application endpoints through Prometheus scraping and Grafana visualization to Alertmanager notification routing. section 3.5

How Machine Learning Platform Engineering covers it

How deep it goes
Explains endpoint exposure, exporter integration, scraping configuration, and querying, but stops short of detailed metric design.
Examples
Uses FastAPI with Starlette Exporter and shows BentoML's automatically generated request-rate and latency metrics.
What it assumes
Assumes an HTTP application and introduces exporter-based instrumentation rather than requiring custom endpoint logic.
What you can do after
Operate/configure Prometheus observability by exposing, scraping, querying, and visualizing application metrics.
How it connects
Connects Prometheus, Grafana, Alertmanager, PromQL, FastAPI, Kubernetes, and BentoML.

Also explained in

Compare how 4 books explain metric endpoint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.