13.10. 数据源统计
您可以查看定义的数据源的核心 池和 JDBC 运行时统计信息。如需了解所有可用 统计数据的详细列表,请参阅 Datasource 统计。
启用数据源统计
默认情况下,不启用 数据源统计信息。以下管理 CLI 命令启用 ExampleDS
数据源的统计信息集合。
注意
在受管域中,在这些命令之前使用 /profile=PROFILE_NAME
。
/subsystem=datasources/data-source=ExampleDS/statistics=pool:write-attribute(name=statistics-enabled,value=true)
/subsystem=datasources/data-source=ExampleDS/statistics=jdbc:write-attribute(name=statistics-enabled,value=true)
查看数据源统计
所有数据源统计信息可以从管理 CLI 检索。这些统计数据的子集可以从管理控制台的 Runtime 选项卡查看。
以下管理 CLI 命令检索 ExampleDS
数据源的核心 池 统计信息。
注意
在受管域中,在这些命令前面带有 /host=HOST_NAME/server=SERVER_NAME
。
/subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "ActiveCount" => 1, "AvailableCount" => 20, "AverageBlockingTime" => 0L, "AverageCreationTime" => 122L, "AverageGetTime" => 128L, "AveragePoolTime" => 0L, "AverageUsageTime" => 0L, "BlockingFailureCount" => 0, "CreatedCount" => 1, "DestroyedCount" => 0, "IdleCount" => 1, ... }
以下管理 CLI 命令检索 ExampleDS
数据源的 JDBC 统计信息。
/subsystem=datasources/data-source=ExampleDS/statistics=jdbc:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "PreparedStatementCacheAccessCount" => 0L, "PreparedStatementCacheAddCount" => 0L, "PreparedStatementCacheCurrentSize" => 0, "PreparedStatementCacheDeleteCount" => 0L, "PreparedStatementCacheHitCount" => 0L, "PreparedStatementCacheMissCount" => 0L, "statistics-enabled" => true } }
注意
由于统计数据是运行时信息,因此请务必指定 include-runtime=true
参数。