tomcatprometheusconnection-poolingjconsolejmx-exporter

How to export Connection pool metrics of Tomcat like NumActive, NumIdle, MaxTotal via JMX exporte?


In JConsole I have fount the metrics of the connection pool I'd like to scrape to Prometheus:

enter image description here

enter image description here Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/postgres",connectionpool=connections

and when I set up the yml file for the export, I don't get the metrics into the /metrics page and they are not scraped

I try with the pattern

- pattern: 'Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/postgres"<>NumIdle: ([0-9]+([.][0-9]+)?)'
  name: jvm_process_jdbc_num_idle
  value: $1
  type: GAUGE

Solution

  • This pattern is working:

    - pattern: 'Catalina<type=DataSource, class=javax.sql.DataSource, name="jdbc/postgres", connectionpool=connections><>(\w+): (\d+)'
      name: jvm_process_jdbc_$1
      value: $2
      type: GAUGE
    

    It produce all the metrics from this MBean's fields that are numbers.

    Note:

    1. < and > instead of : in the JConsole iterface
    2. Spaces after , separator of the parameters and space after : before the numeric value
    3. When checking the /metrics page wait a little bit, it appears not just after the page is loaded, for me it required several dozens of seconds to see those metrics. Before that with the same patter in the firs second after the process has been started, I haven't seen them