You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过JMX获取Keycloak 3.4.3.Final域模式下数据源池统计信息?

Can I Retrieve Keycloak Datasource Pool Statistics via JMX in Domain Mode?

Absolutely, you can access those datasource pool statistics (like ActiveCount, AvailableCount) via JMX—you just need to tweak a few configurations and know where to look, since you’re running Keycloak 3.4.3.Final (built on WildFly) in domain mode. Here’s how to get it working:

1. Ensure Datasource Statistics Are Enabled

First, confirm that statistics are turned on for your datasource. Since you’re in domain mode, this setting lives in the profile your cluster nodes are using:

  • Via WildFly Admin Console: Navigate to Domain > Profiles > [Your Target Profile] > Subsystems > Datasources > [Your Datasource] > Settings, then check the Statistics Enabled box.
  • Via domain.xml: Edit your domain configuration file, find your datasource definition, and add the <statistics enabled="true"/> tag inside the <datasource> or <xa-datasource> block:
    <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS">
        <!-- existing config -->
        <statistics enabled="true"/>
    </datasource>
    

2. Verify JMX Expose Settings in Domain Mode

Domain mode has specific JMX configurations to ensure statistics MBeans are accessible remotely:

  • Open domain.xml and locate the <subsystem xmlns="urn:jboss:domain:jmx:1.3"> section.
  • Make sure these settings are present:
    <expose-resolved-model value="true"/>
    <expose-expression-model value="true"/>
    <remoting-connector use-management-endpoint="true"/>
    
    The remoting-connector ensures JMX connects through the management endpoint, which is essential for remote access in domain mode.

3. Find the Correct MBean Path in JConsole

The static config you’re seeing under jboss.as/auth-server-clustered/datasources isn’t where the live statistics live. Instead, navigate to:

  • For standard datasources: jboss.as/subsystem/datasources/data-source=<YourDatasourceName>/statistics
  • For XA datasources: jboss.as/subsystem/datasources/xa-data-source=<YourXADatasourceName>/statistics

Under this node, you’ll find all the pool metrics you need—ActiveCount, AvailableCount, CreatedCount, DestroyedCount, etc.

4. Ensure Cluster Configuration Consistency

Since you’re running a cluster:

  • Make sure all nodes in your server group are using the same profile with statistics enabled.
  • Restart the server group after modifying configurations to apply changes across all nodes.
  • Double-check that you’re connecting JConsole to the correct node’s JMX port (domain mode assigns unique ports to each server instance; default offsets start at 9999 for the first node).

Quick Troubleshooting Tips

  • Permissions: Ensure the user you’re using to connect JConsole has the monitor role in WildFly’s management realm—this role grants access to read JMX statistics.
  • Connection Port: Confirm you’re using the correct remote JMX port for the target node (you can find this in the server group’s socket bindings in the admin console).

内容的提问来源于stack exchange,提问作者Alex Fil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:41:24