A counter records how often an event occurs. It is a single-value metric that can only be incremented, making it suitable for monotonically increasing totals such as placed orders or registered cars. section 10.3.2
In Quarkus with Micrometer, counters support business metrics alongside framework metrics. Create them declaratively with @Counted or programmatically through MeterRegistry; annotations are shorter, while imperative code provides more flexibility. section 10.3.4
Choose an implementation approach:
- Annotate a CDI bean method with @Counted(name = "orders"). An interceptor registers the counter and increments it by one whenever the method is called. section 10.3.4
- Inject MeterRegistry and call meterRegistry.counter("orders").increment() when the event occurs. The counter method creates the named counter if necessary and returns it. section 10.3.4
- Use Counter.builder(...) when the metric needs a description or other metadata, and register it once before updates begin, such as during @PostConstruct initialization. section 10.3.4
@Counted(name = "orders", description = "Number of orders placed")
public void orderPlaced(OrderDetais details) {
// order processing logic
}
The annotation form connects a method call directly to an incrementing orders counter. section 10.3.4
After enabling the Prometheus registry, inspect counters through /q/metrics. Prometheus output identifies metric types with # TYPE metadata, while Grafana can visualize stored metrics in dashboards. section 10.3.6



