Collect metrics with the Micronaut Framework and monitor them on Oracle Cloud

Learn how to collect standard and custom metrics with the Micronaut framework and monitor them on Oracle Cloud.

Authors: Nemanja Mikic, Burt Beckwith

Micronaut Version: 4.5.0

1. Getting Started

In this guide, we will create a Micronaut application written in Groovy.

We’ll use Micronaut Micrometer to expose application metric data with Micrometer.

2. What you will need

To complete this guide, you will need the following:

  • An Oracle Cloud account (create a free trial account at

  • We’ll use the OCI command line to authenticate ourselves. If you don’t have it already, install the Oracle Cloud CLI and run oci setup config.

3. The Application

Download the complete solution of the Collect Metrics with Micronaut guide. You will use the sample application as a starting point.

4. Monitor metrics on Oracle Cloud

To publish metrics to Oracle Cloud, you have to adjust your application configuration slightly, and then you will be able to create queries and monitor your metrics on the Oracle Cloud Metrics Explorer.

Unresolved directive in micronaut-metrics-oci-maven-groovy.adoc - include::build/code/micronaut-metrics-oci/micronaut-metrics-oci-maven-groovy/src/main/resources/application.yml[tag=metrics]
1 Change to false to disable all metrics, e.g., per-environment
2 These default to true and are only here for convenience, to be able to disable a subset of metrics
3 Change namespace to something meaningful, for an example app name. In this guide we are using micronautguide

By default, metrics will be published in your root compartment (tenancy). If you want to specify in which compartment metrics should be published, you can add compartmentId field inside your configuration. The full path of the key is micronaut.metrics.export.oraclecloud.compartmentId.

4.1. Visit the Oracle Cloud Metrics Explorer.

In the query editor create the query that you want to monitor. You have to specify the compartment (#1), namespace (#2) and the name of the metric (#3).

query editor

After clicking the (#4) Update Chart button you will see values of your selected metric in the Metrics Explorer.

metrics explorer

5. Next steps

Explore more features with Micronaut Guides.

Read more about Micronaut Oracle Cloud integration and how to use advanced monitor queries on the Oracle Cloud Monitoring.

6. License

All guides are released with an Apache license 2.0 license for the code and a Creative Commons Attribution 4.0 license for the writing and media (images…​).