Collecting JMX statistics from every single pod

As my goal, I want to use Jolokia JVM agent with Metricbeat Kubernetes autodiscovery (with Jolokia module) to monitor my Java application statistics.

Usually, we use Deployments to deploy our applications with some HPA's for autoscaling.
And scaling is something that is troublesome for us right now.

We want to get metrics from all Pods of our apps and to be able to distinguish them (to know with which Pod specifically there may be a problem).

For now, we are only able to get the Jolokia module working with autodiscovery Kubernetes Services, but because Services works as LoadBalancers, we are not able to tell, which event is from which Pod (if we have more than 1 replica of the application). Our configuration looks like that:

    - type: kubernetes
      scope: cluster
      resource: service
 	- condition:
	      kubernetes.labels.jolokia-metrics: "enabled"
	    - module: jolokia
	      metricsets: ["jmx"]
	      period: 10s
	      hosts: ["${}.${data.kubernetes.namespace}:9090/jolokia/"]
	      username: jolokia
	      password: <redacted>
	      namespace: ${data.kubernetes.namespace}
	      jmx.mappings: [...]

My question is, how to set Jolokia module (specifically hosts) when we switch from resource: service to resource: pod?
According to documentation (Autodiscover | Metricbeat Reference [7.16] | Elastic), when we switch to Pod resouce, we get these field:

  • kubernetes.container.image
  • kubernetes.namespace
  • kubernetes.pod.uid

Alas, there isn't one with kubernetes.pod.ip that would solve our problem (Metricbeat with hostNetwork: enabled can easily access pods internal IPs)

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