Outline
HikariCP provides a number of monitoring indicators, based on his monitoring indicators are provided MicroMeter out, then Prometheus support and Dropwizard. This time we will discuss HikariCp monitoring indicators of what and why these indicators, and how do we monitor.
Monitoring indicators
Like com.zaxxer.hikari.metrics.PoolStats
that provided several important indicators are stored in poolState in.
totalConnections
total number of connections, and the connection used comprises idle.idleConnections idle connections
activeConnections
active connections
totalConnections = activeConnection + idleConnections
pendingThreads
is waiting for the number of threads connected. When troubleshooting performance problems, this indicator is an important reference, if the thread is waiting for the connection of a larger number for quite some time, you can consider expanding the size of the database connection pool. (Ie HikariCP of maxPoolSize)maxConnections
maximum number of connections, statistical indicators, statistical maximum number of connections so far.minConnections
minimum number of connections, statistical indicators, statistical minimum number of connections so far.usageTime
per connection time, when the connection is recovered it will record this metric:com.zaxxer.hikari.pool.HikariPool#recycle
acquireTime
obtain the wait time for each connection, a database connection request acquisition or a timeout because the failure will record this metric.connectionCreateTime
connection creation time
How to monitor
Here we get more familiar SpringBoot project as an example, while using prometheus and grafana, adding the project relies promethues of:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus:1.3.0'
While adding in SpringBoot project application.properties configuration file the following parameters:
management.endpoints.web.exposure.include=prometheus 暴露prometheus格式化的指标,这样可以被promethues服务器抓取
Next we need to start a prometheus service, https://prometheus.io/download/ then change the default configuration under peometheus service restart, additional configuration is as follows:
- job_name: 'prometheus-test' # job名称
scrape_interval: 5s # 抓取时间间隔,这里每5s像数据源请求一次
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['127.0.0.1:8080'] # 这里是springBoot项目的地址
Grafana then starts a service, https://grafana.com/get added prometheus data source, after starting production dashboard.
Expand knowledge
Micrometer
Vendor-Neutral the Application metrics the Facade (vendor-independent application metrics appearance). We can make it analogous to the log frame slf4j. The promethues analogy to logback. Application directly to rely Micrometer Exposure Indices. Micrometer more popular, it has a built-in indicators as SpringBoot2.0 facade library.Dropwizard
a Java framework, similar to SpringBoot, but the domestic use of less. Which provides metrics related functions.Prometheus
achieve a monitor, based on the pull model, the timing of the image data source prometheus pull index information. Do the analysis, processing and display.