# How to configure jolokia with tomcat using metricbeat?

**URL:** <https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 22, 2018, 11:05am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541 "2018-09-22T11:05:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aftab\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aftab_ali/32/35399_2.png) [@Aftab\_Ali](https://discuss.elastic.co/u/Aftab_Ali)\
**Post date:** [September 22, 2018, 11:05am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/1 "2018-09-22T11:05:04Z")

</div>

Dear Team,

I want to see Tomcat internal metric like JVM memory and Threads count and more,  
i followed the steps:-

Step 1:- download the JAVA agent from [https://jolokia.org/download.html](https://jolokia.org/download.html)  
package name is jolokia-jvm-1.6.0-agent.jar after that i configure it to tomcat startup file like :-- export CATALINA\_OPTS="$CATALINA\_OPTS -javaagent:/jolokia/jolokia-jvm-1.6.0-agent.jar=port=7777,host=localhost"  
in startup.sh in Tomcat binary file and i started tomcat without any error tomcat started,

after that i enabled jolokia module and make changed in jolokia config file like :--

- module: jolokia  
#metricsets: ["jmx"]  
period: 10s  
hosts: ["localhost"]  
namespace: "metrics"  
#path: "/jolokia/?ignoreErrors=true&canonicalNaming=false"  
#username: "user"  
#password: "secret"  
jmx.mappings:
  - mbean: 'java.lang:type=Runtime'  
attributes:
    - attr: Uptime  
field: uptime

  - mbean: 'java.lang:type=Memory'  
attributes:
    - attr: HeapMemoryUsage  
field: memory.heap\_usage
    - attr: NonHeapMemoryUsage  
field: memory.non\_heap\_usage

# GC Metrics - this depends on what is available on your JVM

  - mbean: 'java.lang:type=GarbageCollector,name=ConcurrentMarkSweep'  
attributes:
    - attr: CollectionTime  
field: gc.cms\_collection\_time

I saved and exit, i did not get any data related tomcat APM ?  
and i also checked with localhost:7777 in jolokia config file.

I am getting in kibana error like this 👎  
September 22nd 2018, 16:40:15.092

error making http request: Post [http://localhost/jolokia:](http://localhost/jolokia:) dial tcp 127.0.0.1:80: connect: connection refused

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 25, 2018, 6:35am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/2 "2018-09-25T06:35:49Z")

</div>

What version of Metricbeat are you using? Could you format your config output above to make it more readable?

For some reasons it seems jolokia refuses the connection. Can you connect with `curl` to the jolokia endpoint?

---

<div class="post-metadata">

**Author:** ![Aftab\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aftab_ali/32/35399_2.png) [@Aftab\_Ali](https://discuss.elastic.co/u/Aftab_Ali)\
**Post date:** [September 26, 2018, 5:17am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/4 "2018-09-26T05:17:05Z")

</div>

Hi Ruflin,

I am using metricbeat v 6.4.1 and metricbeat configuration given below :--

###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common

# options. The metricbeat.reference.yml file from the same directory contains all the

# supported options with more comments. You can use it as a reference.

# 

# You can find the full configuration reference here:

# [https://www.elastic.co/guide/en/beats/metricbeat/index.html](https://www.elastic.co/guide/en/beats/metricbeat/index.html)

#========================== Modules configuration ============================

metricbeat.config.modules:

# Glob pattern for configuration loading

path: ${path.config}/modules.d/\*.yml

# Set to true to enable config reloading

reload.enabled: true

# Period on which files under path should be checked for changes

reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:  
index.number\_of\_shards: 1  
index.codec: best\_compression  
#\_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group

# all the transactions sent by a single shipper in the web interface.

#name:

# The tags of the shipper are included in their own field with each

# transaction published.

#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the

# output.

#fields:

# env: staging

#============================== Dashboards =====================================

# These settings control loading the sample dashboards to the Kibana index. Loading

# the dashboards is disabled by default and can be enabled either by setting the

# options here, or by using the `-setup` CLI flag or the `setup` command.

#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL

# has a value which is computed based on the Beat name and version. For released

# versions, this URL points to the dashboard archive on the [artifacts.elastic.co](http://artifacts.elastic.co)

# website.

#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.

# This requires a Kibana endpoint configuration.

setup.kibana:

# Kibana Host

# Scheme and port can be left out and will be set to the default (http and 5601)

# In case you specify and additional path, the scheme is required: [http://localhost:5601/path](http://localhost:5601/path)

# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601

host: "localhost:5601"

#============================= Elastic Cloud ==================================

# These settings simplify using metricbeat with the Elastic Cloud ([https://cloud.elastic.co/](https://cloud.elastic.co/)).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and

# `setup.kibana.host` options.

# You can find the `cloud.id` in the Elastic Cloud web UI.

#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and

# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.

#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------  
output.elasticsearch:

# Array of hosts to connect to.

hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.

#protocol: "https"  
#username: "elastic"  
#password: "changeme"

#----------------------------- Logstash output --------------------------------  
#output.logstash:

# The Logstash hosts

#hosts: ["localhost:5044"]

# Optional SSL. By default is off.

# List of root certificates for HTTPS server verifications

#ssl.certificate\_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication

#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key

#ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

# Sets log level. The default log level is info.

# Available log levels are: error, warning, info, debug

#logging.level: debug

# At debug level, you can selectively enable logging only for some components.

# To enable all selectors use ["\*"]. Examples of other selectors are "beat",

# "publish", "service".

#logging.selectors: ["\*"]

#============================== Xpack Monitoring ===============================

# metricbeat can export internal metrics to a central Elasticsearch monitoring

# cluster. This requires xpack monitoring to be enabled in Elasticsearch. The

# reporting is disabled by default.

# Set to true to enable the monitoring reporter.

#xpack.monitoring.enabled: false

# Uncomment to send the metrics to Elasticsearch. Most settings from the

# Elasticsearch output are accepted here as well. Any setting that is not set is

# automatically inherited from the Elasticsearch output configuration, so if you

# have the Elasticsearch output configured, you can simply uncomment the

# following line.

#xpack.monitoring.elasticsearch:

* * *

Please check...

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 26, 2018, 9:39pm UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/5 "2018-09-26T21:39:29Z")

</div>

Could you please format the above output with 3 ticks before and after to make it readable?

Did you try to run curl?

---

<div class="post-metadata">

**Author:** ![Aftab\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aftab_ali/32/35399_2.png) [@Aftab\_Ali](https://discuss.elastic.co/u/Aftab_Ali)\
**Post date:** [September 27, 2018, 2:15pm UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/6 "2018-09-27T14:15:16Z")

</div>

Yes, I tried this 👎

root@server:/opt/tomcat# curl [http://localhost:7777](http://localhost:7777)  
curl: (7) Failed to connect to localhost port 7777: Connection refused  
root@server:/opt/tomcat# curl -I [http://localhost:7777](http://localhost:7777)  
curl: (7) Failed to connect to localhost port 7777: Connection refused  
root@server:/opt/tomcat# telnet localhost 7777  
Trying 127.0.0.1...  
telnet: Unable to connect to remote host: Connection refused

now i am getting no error in metricbeat:--

| 2018-09-28T10:54:41.205+0530 | INFO | elasticsearch/client.go:712 | Connected to Elasticsearch version 6.4.1 |
| --- | --- | --- | --- |
| 2018-09-28T10:54:41.210+0530 | INFO | template/load.go:129 | Template already exists and will not be overwritten. |
| 2018-09-28T10:54:41.210+0530 | INFO | pipeline/output.go:105 | Connection to backoff(elasticsearch([http://localhost:9200](http://localhost:9200))) established |

But in kibana i am getting error like 👎

error making http request: Post [http://localhost:7777/jolokia:](http://localhost:7777/jolokia:) dial tcp 127.0.0.1:7777: connect: connection refused

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 1, 2018, 7:06am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/7 "2018-10-01T07:06:04Z")

</div>

If you also get an error with curl, I would recommend to look into your jolokia setup on why it does not expose on port 7777.

---

<div class="post-metadata">

**Author:** ![Aftab\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aftab_ali/32/35399_2.png) [@Aftab\_Ali](https://discuss.elastic.co/u/Aftab_Ali)\
**Post date:** [October 1, 2018, 7:11am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/8 "2018-10-01T07:11:31Z")

</div>

Thanks for the reply, I am on it.

---

<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:** [October 29, 2018, 7:11am UTC](https://discuss.elastic.co/t/how-to-configure-jolokia-with-tomcat-using-metricbeat/149541/9 "2018-10-29T07:11:33Z")

</div>

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