liveBook · Manning

Resource tag

As explained in Quarkus in Action

A tag is a key-value label attached to a metric to identify a particular dimension of the measured data.

A resource tag is a key-value label that gives a metric a dimension beyond its name. Metrics can share a name while differing in tag values; each unique combination of values identifies a separate data series. This makes related measurements easier to query and aggregate. section 10.3.3

HTTP request counts

Counters named `http_requests` can carry `method`, `path`, and `status` tags. Aggregate by `method` to count requests using a particular HTTP method, or combine `path` and `status` to count responses for a particular route and status code. section 10.3.3

Choose dimensions with low cardinality: a user ID is a poor tag value because each user has a distinct ID. Quarkus uses dimensions in many built-in metrics, and business metrics can use them where they help answer a query. section 10.3.3

A Micrometer `@Counted` annotation on a method produces counters with `class`, `method`, `exception`, and `result` dimensions. Call the method at least once before looking for its counter at `/q/metrics`: registration is lazy when the owning bean is first instantiated. section 10.3.6

method_counted_total{
class="org.acme.inventory.service.GraphQLInventoryService",
exception="none",
method="register",
result="success"} 1.0

The Prometheus output shows one counted-method series with its tag values and count. section 10.3.6

How Quarkus in Action covers it

How deep it goes
Defines key-value dimensions, explains per-combination series and aggregation, and cautions against high-cardinality values.
Examples
Uses HTTP request method, path, and status tags, plus a counted-method series labeled with class, method, exception, and result.
What it assumes
Introduces metric dimensions from key-value pairs while using HTTP requests and counters as examples.
What you can do after
Apply it via Micrometer `@Counted` and inspect the resulting dimensions at Quarkus’s `/q/metrics` endpoint.
How it connects
Connects metric tags to counters, Micrometer, Prometheus, and Grafana.

Also explained in

Compare how 6 books explain resource tag →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.