liveBook · Manning

Metric endpoint

As explained in Spring AI in Action

A metrics endpoint is an HTTP endpoint that exposes named application measurements and their associated statistics and tags.

A metric endpoint is an HTTP endpoint that exposes named application measurements, statistics, and tags. In a Spring Boot application, Actuator provides the endpoint, while Spring AI records token usage, operation counts, and operation timing. section 9.1

Enable and use the endpoint incrementally:

  • Add the Actuator starter dependency and expose both health and metrics endpoints. section 9.1
  • Start the application and make an application request so that measurements exist. section 9.1
  • Append a metric name to /actuator/metrics and issue a GET request with an HTTP client. section 9.1.1
  • Inspect measurements for COUNT, TOTAL_TIME, and MAX, then use available tags to filter operations. section 9.1.1

Inspecting AI operations

The gen_ai.client.operation metric can distinguish chat and embedding calls, identify the provider and requested or returned model, and report their counts and timing. Filtering by gen_ai.operation.name:embedding shows embedding-specific statistics. section 9.1.2

Inspecting vector store operations

The db.vector.client.operation metric can reveal add, delete, or query activity, the vector-store system, and whether an error occurred. A tag filter such as db.operation.name:add narrows the response. section 9.1.1

implementation 'org.springframework.boot:spring-boot-starter-actuator'

Use the supplied dependency listing to add Spring Boot Actuator. section 9.1

management.endpoints.web.exposure.include=health,metrics

Use the supplied configuration listing to expose health and metrics endpoints. section 9.1

How Spring AI in Action covers it

How deep it goes
Explains dependency setup, endpoint exposure, HTTP inspection, measurements, and tag filtering, but defers dashboard construction and tracing.
Examples
Uses Board Game Buddy, /ask, vector-store operations, OpenAI chat and embedding calls, HTTPie requests, and JSON metric responses.
What it assumes
Assumes a running Spring Boot application and an HTTP client while teaching Actuator dependency and endpoint configuration explicitly.
What you can do after
Operate and diagnose AI applications by enabling Actuator metrics, querying named endpoints, and filtering measurements with tags.
How it connects
Connects Actuator and Micrometer metrics with Spring AI, vector stores, Prometheus, Grafana, and tracing tools.

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 Spring AI in Action. The section links point to the parts of the book it draws on.