Spring Boot JDBC & HikariCP
2,969

Created 3/19/2024
Updated 3/28/2024
Revision 8
Categories
Databases
Datasources
Prometheus

Spring Boot JDBC & HikariCP

Grafana Dashboard of Spring Boot (by Micrometer metrics from Prometheus) for JDBC and HikariCP.

Supported Spring Boot 3.x.

See details in GitHub.

Configure Spring Boot Application

  1. Add one of Spring Boot database modules, for example, Spring Data Jpa or Spring Data JDBC.
  2. Add Spring Boot Actuator module with micrometer-registry-prometheus.
  3. Add configuration, for example, application.yml:
spring:
  application:
    name: myapp
  datasource:
    username: mydb_user
    password: mydb_pass
    url: jdbc:postgresql://localhost:5432/mydb
    hikari:
      minimum-idle: 2
      maximum-pool-size: 8
management:
  endpoints:
    web:
      exposure:
        include:
          - prometheus # Access by /actuator/prometheus
  metrics:
    tags:
      namespace: local # Namespace of k8s
      application: ${spring.application.name}

Configure Prometheus Job

Add job with pulling metrics from /actuator/prometheus, for example, on localhost:8080:

scrape_configs:
  - job_name: myapp-job
    scrape_interval: 15s
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: [ localhost:8080 ]
Get Dashboard
Download
Copy to Clipboard
Source Grafana.com