# Connecting metricbeat to microservices

**URL:** https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001
**Category:** Beats
**Tags:** metricbeat
**Created:** [July 13, 2018, 7:12pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001 "2018-07-13T19:12:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shubhamh](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shubhamh](https://discuss.elastic.co/u/shubhamh)
#### Post date: [July 13, 2018, 7:12pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001/1 "2018-07-13T19:12:33Z")

</div>

Hello,

I am looking to connect Metricbeat with multiple microservices on a node. Each microservice is running jolokia and we are looking to pull all of that data into metricbeat. We currently have metricbeat setup to monitor the system level metrics on the node itself but we were looking to connect to the microservices as well. Would this be possible?

If this is not possible, would it make sense that we create another metricbeat container on the same node to which all microservices would send their jolokia data to and then forward that data onward to the metricbeat that is monitoring the system level metrics? We are looking to have all our data in a central location.

---

<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: [July 13, 2018, 9:25pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001/2 "2018-07-13T21:25:50Z")

</div>

Hi @shubhamh and welcome 🙂

Yes, Metricbeat has a [Jolokia module](https://www.elastic.co/guide/en/beats/metricbeat/6.3/metricbeat-metricset-jolokia-jmx.html) that can be used to collect metrics from JVM applications. For that you can use the metricbeat instance you already have in your node, there is no need to start a container for each microservice. Take into account that Jolokia address has to be reachable by metricbeat.

We recently published a blogpost about monitoring java applications with jolokia and metricbeat, you can read it here: [https://www.elastic.co/blog/monitoring-java-applications-with-metricbeat-and-jolokia](https://www.elastic.co/blog/monitoring-java-applications-with-metricbeat-and-jolokia)

How are you orchestrating your microservices? if you are using kubernetes and/or docker you can use the [autodiscover providers](https://www.elastic.co/guide/en/beats/metricbeat/6.3/configuration-autodiscover.html) to easily manage the configuration, specially after the introduction of [hints-based configuration](https://www.elastic.co/blog/docker-and-kubernetes-hints-based-autodiscover-with-beats).

---

<div class="post-metadata">

### Author: ![shubhamh](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shubhamh](https://discuss.elastic.co/u/shubhamh)
#### Post date: [July 25, 2018, 8:08pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001/3 "2018-07-25T20:08:58Z")

</div>

Hi Jaime,

Sorry for the late reply. We are currently using docker and using DCOS to manage the microservices. We are currently having trouble connecting the module to the microservices. We seem to be getting a connection refused. I have pasted our module configuration on our dcos node below. Can you please advise as to how we can connect our jolokia endpoints to metricbeat? Please let me know if you have any questions. Thank you

metricbeat.modules:

#--------------------System Module------------------

- module: jolokia  
metricsets: ["jmx"]  
enabled: true  
period: 10s  
hosts: ["X.X.X.X:9997"]  
namespace: "metrics"  
jmx.mappings:
- mbean: 'java.lang:type=Runtime'  
attributes:
- attr: Uptime  
field: uptime
- mbean: 'java.lang:type=GarbageCollector,name=ConcurrentMarkSweep'  
attributes:
- attr: CollectionTime  
field: gc.cms\_collection\_time
- attr: CollectionCount  
field: gc.cms\_collection\_count
- mbean: 'java.lang:type=Memory'  
attributes:
- attr: HeapMemoryUsage  
field: memory.heap\_usage
- attr: NonHeapMemoryUsage  
field: memory.non\_heap\_usage

tags: ["jolokia-test"]

#-----------------Logstash Output------------------

metricbeat.autodiscover:  
providers:

- type: docker  
templates:
- condition:  
contains:  
docker.container.image: nexus  
config:
- module: docker  
metricsets: ["leader", "self", "store"]  
hosts: "X.X.X.X:9997"

output.logstash:  
hosts: ["[samplewebsite.com:5044](http://samplewebsite.com:5044)"]  
ssl.enabled: true  
ssl.certificate\_authorities: ["/etc/ca.crt"]  
ssl.certificate: "/etc/client.crt"  
ssl.key: "/etc/client.key"

---

<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: [August 7, 2018, 1:12pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001/4 "2018-08-07T13:12:03Z")

</div>

Hi @shubhamh,

Sorry but I cannot see your configuration very well, could you paste it as preformatted text using the `</>` button?

If the connection refusal happens connecting to jolokia, you may need to check if there is connectivity between metricbeat and jolokia. Jolokia by default uses to listen only on localhost, if you are running metricbeat in a different container you may need to configure jolokia to listen on an interface that metricbeat can reach, or on `0.0.0.0`.

The autodiscover configuration you pasted looks incorrect, in the module template you need to put the module configuration you would use to collect metrics from the container matching the condition. I guess that in your case you'd like to put there the jolokia module configuration.

---

<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: [September 4, 2018, 1:12pm UTC](https://discuss.elastic.co/t/connecting-metricbeat-to-microservices/140001/5 "2018-09-04T13:12:04Z")

</div>

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