Quick Start with Prometheus,Grafana and Springboot

Let's use docker to run prometheus and grafana locally.


 docker pull prom/prometheus

docker run -d --name=prometheus -p 9090:9090 -v <path to  prometheus.yml>:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml

docker run -d --name=grafana -p 3000:3000 grafana/grafana


In springboot, make sure to have actuator and the following dependency

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

and a simple prometheus.yml looks like this

scrape_configs:
- job_name: 'prometheus'

static_configs:
- targets: ['127.0.0.1:9090']

- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['192.168.0.43:8080'] # refer system ip address rather that localhost

Comments