jmx-exporter : problem to export datasource metrics.

114 views
Skip to first unread message

Pascal BEN -BTWIN VILLAGE LILLE-

unread,
Jan 26, 2021, 3:54:53 AM1/26/21
to Prometheus Users

Hi,

I want to export datasource metric, I try many pattern without success

This the list of patterns than I try :

# pattern: 'Catalina<type=DataSource, name="(\w+-\w+)"><>(maxIdle|minIdle|maxWait|active|size|idle|createCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releaseCount):' # JMX Bean: Catalina:type=DataSource, context=[context name],host=[hostname],class=javax.sql.DataSource,name="[JNDI name]" # Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/fwk" #- pattern: 'Catalina<type=DataSource, context="javax.sql.DataSource", host="(\w+)"><>(maxIdle|minIdle|maxWait|active|size|idle|createCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releaseCount):' # pattern: 'Catalina<type=DataSource,class=javax.sql.DataSource,host=([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]),name="(\w+),context=(\w+)"><>(maxIdle|minIdle|maxWait|active|size|idle|createCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releaseCount):' # pattern: 'Catalina<type=DataSource, context=(.*),host=(.*),class=javax.sql.DataSource,name="(.*)"><>(maxIdle|minIdle|maxWait|active|size|idle|createCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releaseCount):' - pattern: 'Catalina<type=DataSource,class=javax.sql.DataSource,name="(.*)"><>(maxIdle|minIdle|maxWait|active|size|idle|createCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releaseCount):' name: tomcat_dataSource_$2 labels: name=: $1 help: Tomcat datasource $1 type: GAUGE 

and an example of the ObjectName  read on Jconsole :  Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/fwk"

Somebody can help me ?  

thank's,
Pascal

Pascal BEN -BTWIN VILLAGE LILLE-

unread,
Jan 27, 2021, 5:57:06 AM1/27/21
to Prometheus Users
Hi,
I resolve my problem.
I found the same question without response, so this is my solution.
if you have a better say me.
@brian.brazil  : to debug my pattern I add 2 log 
  • one to log the matchname : logger.log(Level.FINE,"matchName:"+matchName);
  • one other to log  the pattern : logger.log(Level.FINE, "-----> pattern:" + rule.pattern.toString())
with this to logs I can check and test  my pattern with the real data.

to export the datasource information from catalina  :
- pattern: 'Catalina<type=DataSource, class=javax.sql.DataSource, name="(.*)"><>(maxIdle|minIdle|maxWait|active|size|idle|createdCount|initialSize|reconnectedCount|maxAge|maxActive|releasedIdleCount|releasedCount):'
  name: tomcat_dataSource_$2
  labels:
    datasource_name: "$1"
  help: Tomcat datasource $2
  type: GAUGE

to export the datasource information from tomcat.jdbc  :  
- pattern: 'tomcat.jdbc<name=\"(.*)\", type=ConnectionPool, class=org.apache.tomcat.jdbc.pool.DataSource><>(MaxIdle|MinIdle|MaxWait|Active|Size|Idle|CreatedCount|InitialSize|ReconnectedCount|MaxAge|MaxActive|ReleasedIdleCount|ReleasedCount):'
  name: tomcat_jdbc_$2
  labels:
    datasource_name: "$1"
  help: Tomcat jdbc $2
  type: GAUGE

Pascal
Reply all
Reply to author
Forward
0 new messages