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. We can forward exposed metrics to graphing systems like Grafana and view them in dashboards representing a live view of running microservices. A live view of metrics can improve business performance and improve application availability.

In this chapter, we 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 such as the following:

10.2 Getting started with MicroProfile Metrics

10.2.1 Graphing metrics with Prometheus and Grafana

10.2.2 MicroProfile Metrics

10.2.3 Instrumenting the Account service

10.2.4 Instrumenting the TransactionService

10.2.5 Creating business metrics

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

10.2.7 Micrometer metrics

10.2.8 Simulating a busy production system

Summary