Se afișează postările cu eticheta HikariCP. Afișați toate postările
Se afișează postările cu eticheta HikariCP. Afișați toate postările

sâmbătă, 29 martie 2025

Monitoring HikariCP Metrics Without Micrometer or OpenTelemetry

You can quickly monitor HikariCP connection pool metrics without enabling Micrometer or OpenTelemetry. Just follow these two simple steps:

1. Enable Debug Logging in logback-spring.xml. Add one of the following logging configurations: 

For general Hikari pool logging:

<logger name="com.zaxxer.hikari.pool.HikariPool" level="DEBUG" />
For more detailed logging:
<logger name="com.zaxxer.hikari" level="DEBUG" />
2. Set the Housekeeping Interval via VM Option Set the following JVM option to adjust the logging frequency (default is 30s; this reduces it to 5 seconds):
-Dcom.zaxxer.hikari.housekeeping.periodMs=5000

Example Log Output 

Once enabled, you’ll start seeing logs like this:

2025-03-29 16:30:07,869 DEBUG c.z.h.p.HikariPool[HikariPool-1 housekeeper] - HikariPool-1 - Pool stats (total=2, active=0, idle=2, waiting=0)

Breakdown of Pool Stats: 

  • total=2 - The total number of connections in the pool (both active and idle). 
  • active=0 - The number of connections currently in use (0 means no connections are being used). 
  • idle=2 - The number of available (idle) connections that are not in use. 
  • waiting=0 - The number of threads waiting for a connection (0 means no requests are waiting). 

By enabling this, you get real-time insights into your connection pool without additional monitoring tools.