Chapter 1. Metrics collection for your Quarkus applications

Metrics are quantitative measurements of specific aspects of an application that are used to observe trends and behavior. Individual measurements are collected at regular intervals with each observed numerical value uniquely identified by a string key and additional (optional) tags or labels.

These key-value pairs are then appended to a time series: a sequence of data points indexed over time. Capturing and analyzing metrics can help you identify potential issues and anomalies before they escalate and cause more serious problems.

Note

Metrics cannot be used for diagnostics or problem determination. Visualization tools aggregate individual measurements to provide visualizations of trends. The incident-specific context you need to identify the cause of an observed issue will not be found in aggregated metrics data; you need more detailed trace or log data for problem determination or root cause analysis.

You can collect runtime and application metrics using either the Micrometer library or SmallRye Metrics specifications:

  • Micrometer provides a simple facade over the instrumentation clients for well-known monitoring systems. Quarkus pairs Micrometer with Prometheus to help you monitor and manage your application.
  • SmallRye Metrics is an implementation of the MicroProfile Metrics specification that provides a Prometheus-compatible metrics endpoint.

The Micrometer extension is the recommended approach for gathering application and runtime metrics in Quarkus and provides the following:

  • Dimensional metrics - vendor-neutral interfaces for timers, gauges, counters, distribution summaries, and long task timers with dimensional analysis that, when paired with a dimensional monitoring system, allows for efficient access to a particular named metric with the ability to drill down across its dimensions.
  • Pre-configured bindings - out-of-the-box instrumentation of caches, the class loader, garbage collection, processor utilization, thread pools, and HTTP traffic. Other extensions, like hibernate-orm and mongodb-client, provide additional bindings automatically when enabled.