/spring-boot-prometheus-grafana-sample

This is a sample for monitoring spring boot web application by using Prometheus and Grafana.

Primary LanguageJava

spring-boot-prometheus-grafana-sample

This is a sample for monitoring spring boot web application by using Prometheus and Grafana.

How to run

You must intall docker, and use docker-compose command.

Run application as follows.

$ git clone https://github.com/aha-oretama/spring-boot-prometheus-grafana-sample.git
$ cd spring-boot-prometheus-grafana-sample
$ docker-compose up -d

Three applications are going to start. (Spring boot web application takes a little time to start up.)

Application URL
spring boot web application http://localhost:8080
Prometheus http://localhost:9090
Grafana http://localhost:3000

Prometheus monitors spring boot application. Grafana visualizes prometheus data source.

Set up Grafana's data source

You can login to Grafana by admin/admin. You set up prometheus data source as follows.

item value
Type Prometheus
URL http://localhost:9090
Access direct
Scrap interval 5s

スクリーンショット 2018-02-26 12.21.27.png

Set up graph

I don't explain here. Refer to Prometheus documenatation and Grafana documentation.

Spring boot web application's API

item value
/prometheus Display metrics for prometheus.
/hello Return hello. The durations of process are collected as metrics named hello_controller_say_hello_duration_seconds_count,hello_controller_say_hello_duration_seconds_sum.
/count Return count of requests. The count of request is collected as metrics named count_requests_total.