Before we begin…

.. it’s worth pointing out that, Oracle Application Container Cloud supports basic constructs such as

Ability to profile your (Java) applications using JFR and downloading them for further analysis

Application specific (per instance) memory metrics

Access to application logs

Let’s dive in

the source is available on Github

The high level flow (and the sample app) is dead simple

Prometheus scrapes the Spring Boot app ( HTTP GET ) for metrics and stores them (in this case its the local storage)

) for metrics and stores them (in this case its the local storage) you can then use the Prometheus UI to introspect the metrics in the form of graphs

Solution overview

Let’s explore some of the important components

Prometheus

It is an open source monitoring service which was originally developed at SoundCloud

part of the CNCF

supports time series data model along with a query language

integration hooks with external systems (e.g. Grafana etc.)

Spring Boot (+ Spring Actuator)

Our Spring Boot app is simple and it exposes a REST endpoint using @RestController

Spring Actuator auto-magically enables the app monitoring part using HTTP endpoints

There are many endpoints which Spring Actuator ( spring-boot-starter-actuator ) exposes (e.g. info , health , dump , env , trace etc.), but the sample app only activates the metrics endpoint which exposes information such as JVM memory, threads, system uptime and more etc.

These metrics details are exposed as JSON — this is not the format which Prometheus understands. So, in addition to this, the sample app uses a adapter/transformer layer provided as an add-on module of the Prometheus Java client.

It helps convert the Spring Actuator metrics info (originally JSON) into the plain text format which Prometheus can consume (by default, it is exposed at the /prometheus endpoint)

The following Maven dependency is all that’s required

Maven dependency for Prometheus Spring Boot client

All you need to do is to use the annotations (highlighted below) to activate the plugin

@SpringBootApplication

@RestController

@EnablePrometheusEndpoint

@EnableSpringBootMetricsCollector public class Bootstrap { public static void main(String[] args) {

SpringApplication.run(Bootstrap.class, args);

}

.....

}

That’s about it for an overview… Now it’s time to prepare the application and send it on it’s way to the cloud