Loading [MathJax]/extensions/TeX/AMSsymbols.js

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.

joi, 27 martie 2025

How to Modify a File Inside a Running Docker Container

Let's assume we need to modify the file logback-spring.xml inside the container bb9d1daac389.

docker exec -it bb9d1daac389 sh
# cd /app
# vim logback-spring.xml
/bin/sh: 1: vim: not found
# apt update
# apt install vim
# vim logback-spring.xml
If the container is not based on an Ubuntu image, you can check the OS using cat /etc/os-release and use the corresponding package manager, such as apt, pacman, or another appropriate tool.