How to configure jolokia with tomcat using metricbeat?

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
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 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"
    • mbean: 'java.lang:type=Runtime'
      • attr: Uptime
        field: uptime
    • mbean: 'java.lang:type=Memory'
      • 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'
      • 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 :-1:
September 22nd 2018, 16:40:15.092

error making http request: Post http://localhost/jolokia: dial tcp connect: connection refused

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?

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:

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


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 ==========================

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.


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



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



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

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

This requires a Kibana endpoint configuration.


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

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 (

The setting overwrites the output.elasticsearch.hosts and options.

You can find the in the Elastic Cloud web UI.

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

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


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

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

#-------------------------- Elasticsearch output ------------------------------

Array of hosts to connect to.

hosts: ["localhost:9200"]

Optional protocol and basic auth credentials.

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

#----------------------------- Logstash output --------------------------------

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.


Please check...

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

Did you try to run curl?

1 Like

Yes, I tried this :-1:

root@server:/opt/tomcat# curl http://localhost:7777
curl: (7) Failed to connect to localhost port 7777: Connection refused
root@server:/opt/tomcat# curl -I http://localhost:7777
curl: (7) Failed to connect to localhost port 7777: Connection refused
root@server:/opt/tomcat# telnet localhost 7777
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)) established

But in kibana i am getting error like :-1:

error making http request: Post http://localhost:7777/jolokia: dial tcp connect: connection refused

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.

1 Like

Thanks for the reply, I am on it.

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