prometheus / jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Apache License 2.0
2.97k stars 1.19k forks source link

JDBC connection pool metrics are not getting scraped via JMX exporters #645

Open tenutensing opened 2 years ago

tenutensing commented 2 years ago

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

sbadyjy commented 1 year ago

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

tenutensing commented 1 year ago

@sbadyjy Not yet.

sudersank commented 1 year ago

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

tenutensing commented 1 year ago

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

sudersank commented 1 year ago

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

tenutensing commented 1 year ago

@sudersank Unfortunately no.

fstab commented 1 year ago

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

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

lukechi1219 commented 1 year ago

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

ObjectName objectName = new ObjectName( "com.nv:type=DataSource"

mjiricka commented 3 months ago

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]).

Nirzak commented 2 months ago

Hi to get the JDBC connection pool metrics of weblogic we have to use the following mbean instead of the one that mentioned on the example config.

com.bea

this one: https://docs.oracle.com/cd/E50629_01/wls/WLAPI/weblogic/management/runtime/JDBCOracleDataSourceRuntimeMBean.html

so the whitelist object will be:

- "com.bea:ServerRuntime=*,Type=JDBCOracleDataSourceRuntime,*"

and the rule will be like as follows:

  - pattern: "^com.bea<ServerRuntime=(.+), Name=(.+), Type=(.+)Runtime><>(.+):"
    name: weblogic_$3_$4
    attrNameSnakeCase: true
    labels:
      runtime: $1
      name: $2

metrics will be like as below:

weblogic_jdbcoracledatasource_curr_capacity{name="dbname",runtime="managedserver",} 3.0 weblogic_jdbcoracledatasource_active_connections_current_count{name="dbname",runtime="managedserver",} 2.0

dhoard commented 2 months ago

@Nirzak Thanks for the information!

@tenutensing @sudersank please try @Nirzak's suggestion. The exporter configuration files are examples.