# How to get metrics using jolokia module?

**URL:** <https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [November 27, 2018, 1:37pm UTC](https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349 "2018-11-27T13:37:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilia/32/60042_2.png) [@Ilia](https://discuss.elastic.co/u/Ilia)\
**Post date:** [November 27, 2018, 1:37pm UTC](https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349/1 "2018-11-27T13:37:11Z")

</div>

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&amp;canonicalNaming=false:](http://192.168.0.64/jolokia/%3FignoreErrors=true&amp;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](https://www.elastic.co/guide/en/beats/metricbeat/6.4/metricbeat-module-jolokia.html) of the elastic guide docs?

How can I get it working?

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [December 19, 2018, 5:17pm UTC](https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349/2 "2018-12-19T17:17:50Z")

</div>

Hi @Ilia,

You need to [deploy the jolokia agent](https://jolokia.org/agent/war.html) in Tomcat first, once deployed your configuration should work if tomcat is listening in this IP.

---

<div class="post-metadata">

**Author:** ![Ilia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilia/32/60042_2.png) [@Ilia](https://discuss.elastic.co/u/Ilia)\
**Post date:** [December 21, 2018, 6:20am UTC](https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349/3 "2018-12-21T06:20:22Z")

</div>

> [@Ilia](#):
>
> the port w

Hi @jsoriano,

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

Thank you, anyway.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2019, 6:20am UTC](https://discuss.elastic.co/t/how-to-get-metrics-using-jolokia-module/158349/4 "2019-01-18T06:20:24Z")

</div>

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