Chapter 2. Exposing metrics in your Quarkus applications

Enable metrics in Quarkus 1.11 using the micrometer extension. After you enable it, real-time values of all metrics collected by the micrometer extension are viewed using the /q/metrics endpoint. By default, this endpoint only responds in plain text.

Procedure

  1. Add the quarkus-micrometer-registry-prometheus extension as a dependency to your application:

    ./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-micrometer-registry-prometheus"

    This command adds the following dependency to your pom.xml:

    pom.xml

    <dependency>
          <groupId>io.quarkus</groupId>
        <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
    </dependency>

  2. Enter the following command to display collected metrics on your terminal:

    curl http://localhost:8080/q/metrics
  3. (Optional) To enable the collection of metrics in JSON format using the Micrometer extension, add the following line to the src/main/resources/application.properties file:

    quarkus.micrometer.export.json.enabled=true
  4. Save the changes to the application.properties file.
  5. Use the following command to view metrics in JSON format:

    curl -i -H "Accept: application/json" -H "Content-Type: application/json"
    http://localhost:8080/q/metrics