druid-plus-spring-boot-starter
说明
基于druid 数据源的Spring Boot Starter 实现
- DruidDataSource 自动初始化
- 基于DruidDataSource的动态数据源实现
- 基于AOP+注解实现数据源按需切换
- DruidDataSource数据源监控逻辑
- 基于druid-spring-boot-starter 的扩展
Maven
<dependency>
<groupId>com.github.hiwepy</groupId>
<artifactId>druid-plus-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
Druid的数据源配置
1、Druid DataSource 属性配置
Github Wiki: https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE%E5%B1%9E%E6%80%A7%E5%88%97%E8%A1%A8
spring:
# 数据源配置:
datasource:
# Druid的数据源配置:
druid:
# 异步初始化策略,可加快启动速度。缺省值:false
async-init: true
# 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时;默认 15,推荐配置为:minIdle
initial-size: 5
# 最大连接池数量(按需配置)。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count),如我的服务器2核一个盘那就是 (2*2)+1=5
# core_count: CPU核心数
# effective_spindle_count is the number of disks in a RAID.就是磁盘列阵中的硬盘数
# 例:虚拟机核心数量是8,磁盘是6磁盘的阵列,计算方式为:(8*2)+ 6 = 22
max-active: 10
# 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁
max-wait: 60000
# 最小连接池数量(按需配置);默认 5
min-idle: 5
# 是否开启 keep-alive:即当最小空闲连接空闲了min-evictable-idle-time-millis,执行validationQuery进行keepAlive
keep-alive: true
# 连接保持空闲而不被驱逐的最小时间,缺省:30分钟,超过上限才会被清理,需要注意满足(maxEvictableIdleTimeMillis-minEvictableIdleTimeMillis>timeBetweenEvictionRunsMillis)的条件
min-evictable-idle-time-millis: 1800000
# 连接保持空闲而不被驱逐的最大时间(毫秒),超时而且没被使用则被释放(retired),缺省:7小时,建议设置比数据库超时时长少30秒以上
# 根据MySQL wait_timeout参数值,默认值为28800秒(即8小时)(show variables like '%timeout%';)
max-evictable-idle-time-millis: 25200000
# 超过时间限制是否回收
remove-abandoned: true
# 超过时间限制多长,单位:毫秒 ,180000毫秒=3分钟
remove-abandoned-timeout-millis: 180000
# 用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会其作用。
validation-query: SELECT 1 FROM DUAL
# 申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。建议配置为true,不影响性能,并且保证安全性。
test-while-idle: true
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒;
# 有两个含义:
#1) Destroy线程会检测连接的间隔时间,如果连接空闲时间大于等于minEvictableIdleTimeMillis则关闭物理连接。
#2) testWhileIdle的判断依据,详细看testWhileIdle属性的说明
time-between-eviction-runs-millis: 60000
# 申请连接时执行validationQuery检测连接是否有效 ,做了这个配置会降低性能
test-on-borrow: true
# 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能
test-on-return: false
# 是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql5.5以下的版本中没有PSCache功能,建议关闭掉。5.5及以上版本有PSCache,建议开启。
pool-prepared-statements: true
# 要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100
max-pool-prepared-statement-per-connection-size: 100
#打印druid统计信息:每天打印一次统计信息日志,后续根据日志帮助优化连接池配置和SQL(按需配置, -1表示关闭)
time-between-log-stats-millis: 86400000
2、Druid 监控界面访问配置
Druid内置提供了一个StatViewServlet用于展示Druid的统计信息。
这个StatViewServlet的用途包括:
- 提供监控信息展示的html页面
- 提供监控信息的JSON API
Github Wiki: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatViewServlet%E9%85%8D%E7%BD%AE
注意:使用StatViewServlet,建议使用druid 0.2.6以上版本。
spring:
# 数据源配置:
datasource:
druid:
# 监控界面访问配置:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatViewServlet%E9%85%8D%E7%BD%AE
stat-view-servlet:
# 是否开启,Druid 监控页面功能
enabled: true
# Druid 监控页面访问地址
url-pattern: /druid/*
# Druid 监控页面登录用户名
login-username: admin
# Druid 监控页面登录密码
login-password: admin
# 是否允许清空统计数据 默认值:false
reset-enable: false
# IP 白名单(没有配置或者为空,则允许所有访问)
allow: 192.168.3.1/24
3、Druid和Spring关联监控配置
Druid提供了Spring和Jdbc的关联监控。
spring:
# 数据源配置:
datasource:
druid:
# Druid和Spring关联监控配置:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_Druid%E5%92%8CSpring%E5%85%B3%E8%81%94%E7%9B%91%E6%8E%A7%E9%85%8D%E7%BD%AE
aop-patterns: com.**.service.**.*Service
4、Druid Session 状态信息采集配置
WebStatFilter用于采集web-jdbc关联监控的数据。
Github Wiki: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter
spring:
# 数据源配置:
datasource:
druid:
# WebStatFilter 配置:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter
web-stat-filter:
# 是否启用 WebStatFilter,默认值:false
enabled: true
# 是否启用 WebStatFilter 的 URL Pattern,默认值:/*,即所有请求都会被拦截
url-pattern: /*
# WebStatFilter 忽略拦截的路径表达式,默认值:*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
# 是否启用 Session 统计功能,默认值:false
session-stat-enable: true
# 最大允许统计多少个 Session
session-stat-max-count: 20000
# 设置 druid 从 Session 中存获取当前的 user 信息的 Key,注意:如果你 session 中保存的是非 string 类型的对象,需要重载 toString 方法,否则会报错
principal-session-name: 'xxx.user'
# 如果你的 user 信息保存在 cookie 中,你可以配置 principalCookieName,根据需要,把其中的 xxx.user 修改为你 user 信息保存在 cookie 中的 cookieName
principal-cookie-name: 'xxx.user'
# druid 0.2.7版本开始支持profile,配置 profileEnable 能够监控单个 url 调用的 sql 列表
profile-enable: true
5、Druid 慢SQL统计
Druid内置提供一个StatFilter,用于统计监控信息。
Github Wiki: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter
spring:
# 数据源配置:
datasource:
druid:
# Druid的监控统计功能:属性类型是字符串,通过别名的方式配置扩展插件
filters: mergeStat
# Druid 自定义过滤器参数
filter:
# 慢SQL统计 :https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter
stat:
# 是否开启 StatFilter,默认值:false
enabled: true
# 是否启用连接池中的连接获取栈信息。如果将其设置为 true,则在日志中会输出详细的连接获取栈信息,方便调试和分析连接使用情况。如果设置为 false,则不会输出这些信息。默认值为 false。
connection-stack-trace-enable: true
# 是否启用慢SQL记录,默认值:false
log-slow-sql: true
# 用于设置 SQL 执行时间超过多少毫秒时认为是慢查询。如果为 true 则会在日志中输出执行时间超过这个阈值的 SQL 语句及其执行时间。
slow-sql-millis: 3000
# 慢SQL日志级别:DEBUG、INFO、WARN、ERROR,默认值:ERROR
slow-sql-log-level: "ERROR"
# 是否启用SQL统计合并功能,默认值:false
merge-sql: true
6、Druid 使用slf4j进行日志输出
可以通过Slf4j的配置使用Log4j2日志组件进行日志的打印。
spring:
# 数据源配置:
datasource:
druid:
# Druid的监控统计功能:属性类型是字符串,通过别名的方式配置扩展插件
filters: mergeStat,slf4j
# Druid 自定义过滤器参数
filter:
# Druid中使用log4j2进行日志输出:https://github.com/alibaba/druid/wiki/Druid%E4%B8%AD%E4%BD%BF%E7%94%A8log4j2%E8%BF%9B%E8%A1%8C%E6%97%A5%E5%BF%97%E8%BE%93%E5%87%BA
slf4j:
# 是否开启日志输出
enabled: true
# Statement 创建后是否打印日志
statement-create-after-log-enabled: false
# Statement 关闭后是否打印日志
statement-close-after-log-enabled: false
# ResultSet 打开后是否打印日志
result-set-open-after-log-enabled: false
# ResultSet 关闭后是否打印日志
result-set-close-after-log-enabled: false
7、Druid 配置安全防护配置
开启 Wallfilter 功能,并根据生产需求进行配置,可有效的进行精细化的安全防护,提前屏蔽掉一些潜在的风险。
Github Wiki: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter
spring:
# 数据源配置:
datasource:
druid:
# Druid的监控统计功能:属性类型是字符串,通过别名的方式配置扩展插件
filters: mergeStat,slf4j,wall
# Druid 自定义过滤器参数
filter:
# Druid防御SQL注入:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter
wall:
# 对被认为是攻击的SQL进行LOG.error输出
log-violation: true
# 对被认为是攻击的SQL抛出SQLExcepton
throw-exception: true
# 配置白名单
config:
# 是否允许语句中存在注释,Oracle的用户不用担心,Wall能够识别hints和注释的区别
comment-allow: true
# 是否允许非以上基本语句的其他语句,缺省关闭,通过这个选项就能够屏蔽DDL
none-base-statement-allow: true
# 是否允许一次执行多条语句,缺省关闭
multi-statement-allow: true
# 解除union关键字检查
select-union-check: false
# 是否允许执行锁定表操作
lock-table-allow: true
Druid 集成 Prometheus 监控
项目中引入 micrometer-prometheus 依赖,可实现 Druid
组件的指标采集
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.hiwepy/druid-metrics-prometheus -->
<dependency>
<groupId>com.github.hiwepy</groupId>
<artifactId>druid-metrics-prometheus</artifactId>
<version>${druid-metrics.version}</version>
</dependency>
采集指标如下:
# HELP druid_statement_create_count Jdbc Statement Create count
# TYPE druid_statement_create_count gauge
druid_statement_create_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_execute_count Execute count
# TYPE druid_execute_count gauge
druid_execute_count{application="app-test",pool="dataSource",} 1.0
# HELP druid_resultset_close_count Jdbc ResultSet Close count
# TYPE druid_resultset_close_count gauge
druid_resultset_close_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_max_active Max active
# TYPE druid_max_active gauge
druid_max_active{application="app-test",pool="dataSource",} 256.0
# HELP druid_execute_batch_count Execute batch count
# TYPE druid_execute_batch_count gauge
druid_execute_batch_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_query_timeout Query timeout
# TYPE druid_query_timeout gauge
druid_query_timeout{application="app-test",pool="dataSource",} 0.0
# HELP druid_statement_execute_success_count Jdbc Statement Execute success count
# TYPE druid_statement_execute_success_count gauge
druid_statement_execute_success_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_start_transaction_count Start transaction count
# TYPE druid_start_transaction_count gauge
druid_start_transaction_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_physical_connect_error_count Physical connect error count
# TYPE druid_physical_connect_error_count gauge
druid_physical_connect_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_commit_count Commit count
# TYPE druid_commit_count gauge
druid_commit_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_resultset_opening_max Jdbc ResultSet Opening max
# TYPE druid_resultset_opening_max gauge
druid_resultset_opening_max{application="app-test",pool="dataSource",} 1.0
# HELP druid_statement_nano_total Jdbc Statement Nano count
# TYPE druid_statement_nano_total gauge
druid_statement_nano_total{application="app-test",pool="dataSource",} 1.479988E8
# HELP druid_connections_error_count Connection error count
# TYPE druid_connections_error_count gauge
druid_connections_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_validation_query_timeout Validation query timeout
# TYPE druid_validation_query_timeout gauge
druid_validation_query_timeout{application="app-test",pool="dataSource",} -1.0
# HELP druid_prepared_statement_open_count Prepared statement open count
# TYPE druid_prepared_statement_open_count gauge
druid_prepared_statement_open_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_login_timeout Login timeout
# TYPE druid_login_timeout gauge
druid_login_timeout{application="app-test",pool="dataSource",} 0.0
# HELP druid_logic_connect_error_count Logic connect error count
# TYPE druid_logic_connect_error_count gauge
druid_logic_connect_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_execute_success_count Jdbc Sql Execute success count
# TYPE druid_sql_execute_success_count gauge
druid_sql_execute_success_count{application="app-test",pool="dataSource",sql="select 'x'",} 6.0
# HELP druid_active_peak Active peak
# TYPE druid_active_peak gauge
druid_active_peak{application="app-test",pool="dataSource",} 1.0
# HELP druid_rollback_count Rollback count
# TYPE druid_rollback_count gauge
druid_rollback_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_pooling_count Pooling count
# TYPE druid_pooling_count gauge
druid_pooling_count{application="app-test",pool="dataSource",} 5.0
# HELP druid_not_empty_thread_count Not empty thread count
# TYPE druid_not_empty_thread_count gauge
druid_not_empty_thread_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_logic_close_count Logic close count
# TYPE druid_logic_close_count gauge
druid_logic_close_count{application="app-test",pool="dataSource",} 2.0
# HELP druid_ps_cache_miss_count PS cache miss count
# TYPE druid_ps_cache_miss_count gauge
druid_ps_cache_miss_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_skip_count Skip Sql Count
# TYPE druid_sql_skip_count gauge
druid_sql_skip_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_statement_prepare_call_count Jdbc Statement Prepare call count
# TYPE druid_statement_prepare_call_count gauge
druid_statement_prepare_call_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_execute_millis_total Jdbc Sql Execute millis total
# TYPE druid_sql_execute_millis_total gauge
druid_sql_execute_millis_total{application="app-test",pool="dataSource",sql="select 'x'",} 147.0
# HELP druid_sql_execute_batch_size_total Jdbc Sql Execute Batch Size Total
# TYPE druid_sql_execute_batch_size_total gauge
druid_sql_execute_batch_size_total{application="app-test",pool="dataSource",sql="select 'x'",} 0.0
# HELP druid_connections_close_count Connection close count
# TYPE druid_connections_close_count gauge
druid_connections_close_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_execute_batch_size_max Jdbc Sql Execute Batch Size Max
# TYPE druid_sql_execute_batch_size_max gauge
druid_sql_execute_batch_size_max{application="app-test",pool="dataSource",sql="select 'x'",} 0.0
# HELP druid_statement_error_count Jdbc Statement Execute error count
# TYPE druid_statement_error_count gauge
druid_statement_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_execute_millis_max Jdbc Sql Execute millis max
# TYPE druid_sql_execute_millis_max gauge
druid_sql_execute_millis_max{application="app-test",pool="dataSource",sql="select 'x'",} 111.0
# HELP druid_resultset_open_count Jdbc ResultSet Open count
# TYPE druid_resultset_open_count gauge
druid_resultset_open_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_resultset_error_count Jdbc ResultSet Error count
# TYPE druid_resultset_error_count gauge
druid_resultset_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_error_count Error count
# TYPE druid_error_count gauge
druid_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_connections_connect_error_count Connection connect error count
# TYPE druid_connections_connect_error_count gauge
druid_connections_connect_error_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_ps_cache_access_count PS cache access count
# TYPE druid_ps_cache_access_count gauge
druid_ps_cache_access_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_max_wait_thread_count Max wait thread count
# TYPE druid_max_wait_thread_count gauge
druid_max_wait_thread_count{application="app-test",pool="dataSource",} -1.0
# HELP druid_active_count Active count
# TYPE druid_active_count gauge
druid_active_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_statement_prepare_count Jdbc Statement Prepare count
# TYPE druid_statement_prepare_count gauge
druid_statement_prepare_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_execute_query_count Execute query count
# TYPE druid_execute_query_count gauge
druid_execute_query_count{application="app-test",pool="dataSource",} 1.0
# HELP druid_sql_execute_error_count Jdbc Sql Execute error count
# TYPE druid_sql_execute_error_count gauge
druid_sql_execute_error_count{application="app-test",pool="dataSource",sql="select 'x'",} 0.0
# HELP druid_statement_execute_millis_total Jdbc Statement Execute millis total
# TYPE druid_statement_execute_millis_total gauge
druid_statement_execute_millis_total{application="app-test",pool="dataSource",} 147.0
# HELP druid_transaction_query_timeout Transaction query timeout
# TYPE druid_transaction_query_timeout gauge
druid_transaction_query_timeout{application="app-test",pool="dataSource",} 0.0
# HELP druid_sql_concurrent_max Jdbc Sql Concurrent max
# TYPE druid_sql_concurrent_max gauge
druid_sql_concurrent_max{application="app-test",pool="dataSource",sql="select 'x'",} 1.0
# HELP druid_execute_update_count Execute update count
# TYPE druid_execute_update_count gauge
druid_execute_update_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_connection_connect_alive_millis_max Connection connect max time
# TYPE druid_connection_connect_alive_millis_max gauge
druid_connection_connect_alive_millis_max{application="app-test",pool="dataSource",} 838.0
# HELP druid_connections_rollback_count Connection rollback count
# TYPE druid_connections_rollback_count gauge
druid_connections_rollback_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_physical_connect_count Physical connect count
# TYPE druid_physical_connect_count gauge
druid_physical_connect_count{application="app-test",pool="dataSource",} 5.0
# HELP druid_connections_alive_max_time Connection alive max time
# TYPE druid_connections_alive_max_time gauge
druid_connections_alive_max_time{application="app-test",pool="dataSource",} 0.0
# HELP druid_resultset_opening_count Jdbc ResultSet Opening count
# TYPE druid_resultset_opening_count gauge
druid_resultset_opening_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_pooling_peak Pooling peak
# TYPE druid_pooling_peak gauge
druid_pooling_peak{application="app-test",pool="dataSource",} 5.0
# HELP druid_connections_commit_count Connection commit count
# TYPE druid_connections_commit_count gauge
druid_connections_commit_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_min_idle Min idle
# TYPE druid_min_idle gauge
druid_min_idle{application="app-test",pool="dataSource",} 5.0
# HELP druid_ps_cache_hit_count PS cache hit count
# TYPE druid_ps_cache_hit_count gauge
druid_ps_cache_hit_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_connections_active_count Connection active count
# TYPE druid_connections_active_count gauge
druid_connections_active_count{application="app-test",pool="dataSource",} 5.0
# HELP druid_sql_execute_count Jdbc Sql Execute count
# TYPE druid_sql_execute_count gauge
druid_sql_execute_count{application="app-test",pool="dataSource",sql="select 'x'",} 6.0
# HELP druid_statement_concurrent_max Jdbc Statement Concurrent max
# TYPE druid_statement_concurrent_max gauge
druid_statement_concurrent_max{application="app-test",pool="dataSource",} 1.0
# HELP druid_max_wait Max wait
# TYPE druid_max_wait gauge
druid_max_wait{application="app-test",pool="dataSource",} 60000.0
# HELP druid_resultset_fetch_row_count Jdbc ResultSet Fetch row count
# TYPE druid_resultset_fetch_row_count gauge
druid_resultset_fetch_row_count{application="app-test",pool="dataSource",} 1.0
# HELP druid_physical_close_count Physical close count
# TYPE druid_physical_close_count gauge
druid_physical_close_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_statement_running_count Jdbc Statement Running count
# TYPE druid_statement_running_count gauge
druid_statement_running_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_statement_execute_count Jdbc Statement Execute count
# TYPE druid_statement_execute_count gauge
druid_statement_execute_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_sql_in_transaction_count Jdbc Sql In transaction count
# TYPE druid_sql_in_transaction_count gauge
druid_sql_in_transaction_count{application="app-test",pool="dataSource",sql="select 'x'",} 0.0
# HELP druid_statement_close_count Jdbc Statement Close count
# TYPE druid_statement_close_count gauge
druid_statement_close_count{application="app-test",pool="dataSource",} 6.0
# HELP druid_transaction_threshold_millis Transaction threshold millis
# TYPE druid_transaction_threshold_millis gauge
druid_transaction_threshold_millis{application="app-test",pool="dataSource",} 0.0
# HELP druid_connections_connect_count Connection connect count
# TYPE druid_connections_connect_count gauge
druid_connections_connect_count{application="app-test",pool="dataSource",} 5.0
# HELP druid_logic_connect_count Logic connect count
# TYPE druid_logic_connect_count gauge
druid_logic_connect_count{application="app-test",pool="dataSource",} 2.0
# HELP druid_not_empty_wait_millis Not empty wait millis
# TYPE druid_not_empty_wait_millis gauge
druid_not_empty_wait_millis{application="app-test",pool="dataSource",} 0.0
# HELP druid_initial_size Initial size
# TYPE druid_initial_size gauge
druid_initial_size{application="app-test",pool="dataSource",} 5.0
# HELP druid_max_open_prepared_statements Max open prepared statements
# TYPE druid_max_open_prepared_statements gauge
druid_max_open_prepared_statements{application="app-test",pool="dataSource",} 20.0
# HELP druid_connections_alive_min_time Connection alive min time
# TYPE druid_connections_alive_min_time gauge
druid_connections_alive_min_time{application="app-test",pool="dataSource",} 0.0
# HELP druid_wait_thread_count Wait thread count
# TYPE druid_wait_thread_count gauge
druid_wait_thread_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_not_empty_wait_count Not empty wait count
# TYPE druid_not_empty_wait_count gauge
druid_not_empty_wait_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_prepared_statement_closed_count Prepared statement closed count
# TYPE druid_prepared_statement_closed_count gauge
druid_prepared_statement_closed_count{application="app-test",pool="dataSource",} 0.0
# HELP druid_max_pool_prepared_statement_per_connection_size Max pool prepared statement per connection size
# TYPE druid_max_pool_prepared_statement_per_connection_size gauge
druid_max_pool_prepared_statement_per_connection_size{application="app-test",pool="dataSource",} 20.0
Sample
https://github.com/vindell/spring-boot-starter-samples/tree/master/spring-boot-sample-druid
最后编辑:Jeebiz 更新时间:2024-10-05 00:01