How to get metrics using jolokia module?

I want to get some metrics from an application that is run using tomcat. I've configured jolokia module as follows:

- module: jolokia
  metricsets: ["jmx"]
  enabled: true
  period: 5s
  fields:
    app: jmx
  hosts: ["192.168.0.64"]
  namespace: "databaseconnectionpool"
  path: "/jolokia/?ignoreErrors=true&canonicalNaming=false"
  jmx.mappings:
#    - mbean: 'com.jolbox.bonecp:type=BoneCP'
    - mbean: 'com.jolbox.bonecp:name=BoneCP'
      attributes:
        - attr: TotalCreatedConnections
          field: TotalCreatedConnections
        - attr: TotalFree
          field: TotalFree
        - attr: TotalLeased
          field: TotalLeased

but in error.message field I get this error:

error making http request: Post http://192.168.0.64/jolokia/%3FignoreErrors=true&canonicalNaming=false: dial tcp 192.168.0.64:80: connect: connection refused

I can see the BoneCP mbean using jvisualvm without setting any port for jmx neither in application nor in jvisualvm to connect to the application. As far as I know jolokia is a tool for jmx over http but don't know if it is for export or for import or for both. If it exports jmx over http I think I should add it to the classpath of the application and specify a port for it. If so, why the port was not specified in example configuration of the elastic guide docs?

How can I get it working?

Hi @Ilia,

You need to deploy the jolokia agent in Tomcat first, once deployed your configuration should work if tomcat is listening in this IP.

Hi @jsoriano,

I did do that after I asked the question and could to get jolokia module working.

Thank you, anyway.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.