liveBook · Manning

Metric

As explained in Machine Learning Platform Engineering

A custom metric is an application-defined quantitative measurement exposed for monitoring a specific behavior or outcome.

A custom metric exposes application-defined measurements that default service metrics cannot capture. Use one to monitor behavior important to the business, support alerting, or report changes in model outcomes. section 11.1.1

Build a custom metric into a deployed inference service by:

  • Installing prometheus-client and defining a Prometheus metric with a name, documentation, and suitable value buckets or counters. section 11.1.2
  • Updating the service logic to record each relevant observation, such as calling observe with an inference confidence score. section 11.1.2
  • Serving the application, checking the /metrics endpoint, and plotting the exposed values in Grafana through Prometheus. section 11.1.2

Object-detection confidence

An object-detection service records confidence scores in decile buckets from 0 to 1. A histogram reveals score distributions and can expose periods of poor image quality or degrading model performance. Grafana can visualize the data and calculate a 90th percentile with histogram_quantile. section 11.1.2

Business behavior counters

A recommendation service can count requests where ranked movies are present or absent, then display those counters as a Grafana line chart. section 11.1.2

confidence_histogram = Histogram(
    name="confidence_score",
    documentation="The confidence score of the prediction",
    buckets=(
      0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1
    ),
)

Inspect the Histogram definition that names the confidence metric, documents its purpose, and assigns decile buckets. section 11.1.2

How Machine Learning Platform Engineering covers it

How deep it goes
Defines metric types, records observations in service code, verifies /metrics exposure, and visualizes results in Grafana.
Examples
Uses object-detection confidence histograms and recommendation-request counters for concrete monitoring cases.
What it assumes
Assumes a BentoML inference service and Prometheus/Grafana monitoring setup while demonstrating metric creation from the implementation level.
What you can do after
Build it from scratch with prometheus-client, expose observations from inference code, and query them in Grafana.
How it connects
Connects Prometheus metrics with BentoML services, Grafana dashboards, histograms, counters, and PromQL.

Also explained in

Compare how 16 books explain metric →

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.