Prometheus Jmx Exporter Operator
This operator using Jmx Exporter enables Java processes running ok Kubernetes Pods to expose metrics collected form mBeans via JMX to Prometheus.
Prometheus JMX Exporter Configuration
configuration file for the JMX Exporter.Create a
Note that in our case
jmxUrl should not be set as the Jmx Exporter agent will be loaded into the Java process and we want it to talk to the local JVM. More configuration examples of Prometheus JMX Exporter can be found here
kubectl create cm <your-prometheus-jmx-exporter-configmap-name> --from-file=<path-to-the-config-file>
kubectl create cm prometheus-jmx-exporter-config --from-file=javadummy/config.yaml kubectl describe cm prometheus-jmx-exporter-config
kubectl create -f <path-to-rbac-yaml-file>
Deploy the operator to Kubernetes
Download the operator.yaml deployment file. If you don't have RBAC enabled than remove
kubectl create -f <path-to-your-operator-yaml-file>
Download cr.yaml and customize it for your needs.
spec: labelSelector: app: dummyapp
The label selector specifies what pods the operator to watch. The operator will investigate the pods that have labels which matches what is specified in
It checks the containers of the pod and the Java applications running in these containers.
It will load the Prometheus JMX Exporter into the Java applications and passes to it the configuration from the config map.
config: configMapName: prometheus-jmx-exporter-config configMapKey: config.yaml
Note: see Prometheus JMX Exporter Configuration above
This is the port number at which Prometheus server can scrape the metrics exported by Prometheus JMX exporter. Chose a port that is not conflicting with any of the container ports already used by the applications running in the containers.
List the JMX Exporter endpoints managed by the operator
kubectl get prometheusjmxexporter kubectl get prometheusjmxexporter <name-of-the-prometheus-jmx-exporter> -o yaml
status section lists the endpoints.
Currently only one Java process per pod is being supported. In case a pod has multiple containers than the operator will select the first container from the list of containers returned by Kubernetes API. Also if a container has multiple java processes running than the operator works on the first process.
Currently the user is required to provide a port for the Prometheus JMX Exporter that doesn't conflict with ports already being used by processes running on the pod. The operator should take care of this by choosing a free port available in the container.
Investigate the possibility of supporting pods with multiple containers and multiple Java processes per container. This operator best works with microservices where there is one process per container.