chapter ten

10 Capturing metrics

 

This chapter covers:

  • The role of metrics in a microservices architecture
  • Types of metrics
  • Creating custom metrics
  • Metrics scopes
  • Viewing metrics in Grafana
  • MicroProfile Metrics and Micrometer metrics

MicroProfile Metrics exposes runtime metrics like CPU and memory utilization and can also expose custom application performance and business metrics. Exposed metrics can be forwarded to graphing systems like Grafana and viewed in dashboards representing a live view of running microservices. A live view of metrics can improve business performance and improve application availability.

This chapter will instrument the Chapter 7 Account Service and Transaction Service with metrics using MicroProfile Metrics APIs, with a section covering the Quarkus Micrometer metrics extension.

The following section explains the benefits of metrics.

10.1 The role of metrics in a microservices architecture

Instrumenting runtimes and applications with metrics offer benefits like the following:

10.2 Getting started with MicroProfile Metrics

10.3 Graphing metrics with Prometheus and Grafana

10.4 MicroProfile Metrics

10.4.1 MicroProfile Metrics output formats

10.4.2 Annotated Metrics naming convention

10.4.3 MicroProfile Metrics scopes

10.4.4 MicroProfile Metrics supported types

10.5 Instrumenting the Account Service

10.6 Instrumenting the TransactionService

10.7 Creating business metrics

10.8 MicroProfile Fault Tolerance and JAX-RS integration with MicroProfile Metrics

10.9 Micrometer metrics

10.10 Simulating a busy production system

10.11 Summary