jmx_exporter icon indicating copy to clipboard operation
jmx_exporter copied to clipboard

JDBC connection pool metrics are not getting scraped via JMX exporters

Open tenutensing opened this issue 4 years ago • 11 comments
trafficstars

Hi there,

JDBC connection pool metrics are not getting scraped via JMX exporters. Configured JMX exporter in both WebLogic, WebSphere and Tomcat. In all 3 cases, scraped metrics doesn’t show up JDBC connection pool metrics.

I’m trying to scrape the JDBC metrics like - https://docs.oracle.com/cd/E25178_01/apirefs.1111/e13952/pagehelp/JDBCjdbcdatasourcesjdbcdatasourcemonitorstatisticstitle.html

Can somebody help me to figure out the configurations to be done if any, in order to expose the JDBC connection pool via JMX exporters?

JMX version – jmx_prometheus_javaagent-0.16.1.jar Java version – 1.8.0_251 WebLogic Server version – 12.2.1.4.0 WebSphere Server version – 9.0.5.6 Tomcat Server version - 8.5.66

WebLogic configuration – “-javaagent://jmx_prometheus_javaagent-0.16.1.jar=25031://config.yaml -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder”

WebSphere configuration – “-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -javaagent://jmx_prometheus_javaagent-0.16.1.jar=25031://config.yaml"”

Tomcat configuration – ““-javaagent://jmx_prometheus_javaagent-0.16.1.jar=25031://config.yaml”

Tried with below “config.yaml” contents first. As per my understanding, all the default metrics will get scrapped, if we do not blacklist or whitelist any objects.

startDelaySeconds: 0 ssl: false lowercaseOutputName: false lowercaseOutputLabelNames: false

Above configuration, didn’t scrape the JDBC metrics. Hence tried whitelisting "com.bea:ServerRuntime=,Type=JDBCDataSourceRuntime,", but this too was not fruitful (https://github.com/prometheus/jmx_exporter/blob/master/example_configs/weblogic.yml).

Regards, Tenu

tenutensing avatar Oct 27 '21 13:10 tenutensing

Hello, I also encountered this problem, has this problem been solved?

sbadyjy avatar Sep 15 '22 03:09 sbadyjy

@sbadyjy Not yet.

tenutensing avatar Sep 15 '22 03:09 tenutensing

@tenutensing were you able to solve this pls?. using jboss eap and not able to scrap the jdbc connection pool metrics.

sudersank avatar Oct 19 '22 01:10 sudersank

@sudersank No. It's not working with this exporter OOTB.

tenutensing avatar Oct 19 '22 01:10 tenutensing

Thank you for the response. is there any workaround that you are aware of to get the metrics. thanks in advance

sudersank avatar Oct 19 '22 02:10 sudersank

@sudersank Unfortunately no.

tenutensing avatar Oct 19 '22 09:10 tenutensing

I guess there is a misunderstanding how jmx_exporter accesses JMX beans. There are two ways to run jmx_exporter:

  • As a Java agent. You attach it to a JVM at startup using the -javaagent parameter. Then jmx_exporter can access JMX beans directly and does not need remote JMX access.
  • As a standalone HTTP server. Then jmx_exporter connects to the application via remote JMX, and the application needs the com.sun.management.jmxremote... parameters to expose JMX on a TCP port.

In the example you are using both, -javaagent and JMX remote, this should not be needed at all.

fstab avatar Oct 19 '22 09:10 fstab

There 1 way to get the metrics. dbPoolName can be any name you want.

ObjectName objectName = new ObjectName( "com.nv:type=DataSource" + ",name=" + this.dbPoolName);

				/*
				 * MEMO: register datasource into jmx.
				 * ref: https://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html#JMX
				 * preRegister() -> registerJmx()
				 */
				datasource.preRegister(null, objectName);

				logger.log(Level.INFO, "jmx register success, objectName : " + objectName);

lukechi1219 avatar May 22 '23 04:05 lukechi1219

I don't know how it looks like on WebLogic, but on Tomcat I get metrics like Catalina_DataSource_NumActive or Catalina_DataSource_BorrowedCount. Metrics like "Active Connections Average Count" or "Active Connections High Count" from the document you linked can be calculated later directly inside Prometheus, e.g. avg_over_time(Catalina_DataSource_numActive{name="\"jdbc/default\""}[1m]) or max_over_time(Catalina_DataSource_numActive{name="\"jdbc/default\""}[1m]).

mjiricka avatar Mar 21 '24 15:03 mjiricka