Skip to main content

Access JMX metrics via Jolokia

Jolokia is one of the external metrics integrations supported on the Aiven platform, along with Datadog metrics and Prometheus metrics.

note

JMX metrics via Jolokia are only supported for Aiven for Apache Kafka® services.

Configure a Jolokia endpoint

To enable Jolokia integration, create a Jolokia endpoint:

  1. In the Aiven Console, select your project.
  2. Click Integration endpoints in the sidebar.
  3. Click Jolokia in the list of integration types.
  4. Click Add new endpoint.
  5. Enter an endpoint name and click Create.

A username and password are generated automatically. You can reuse the same Jolokia endpoint for multiple services in the same project.

Enable Jolokia integration

To enable Jolokia integration for an Aiven for Apache Kafka® service:

  1. In the Aiven Console, select your Aiven for Apache Kafka service.
  2. On the Overview page, click Integrations.
  3. Under Endpoint integrations, click Jolokia.
  4. Select the Jolokia endpoint you created and click Enable.

This configures the endpoint on all service nodes and provides access to JMX metrics.

Jolokia supports HTTP POST requests to retrieve service-specific metrics and bulk requests to collect metrics in batches. For details, see the Jolokia protocol documentation.

Several metrics are specific to individual Kafka® brokers. To get a complete view of the cluster, you might need to query each broker. The brokers share a DNS name. Use the host command (on Unix) or nslookup (on Windows) to list the associated IP addresses.

host kafka-67bd7c5-myproject.aivencloud.com
kafka-67bd7c5-myproject.aivencloud.com has address 35.228.218.115
kafka-67bd7c5-myproject.aivencloud.com has address 35.228.234.106
kafka-67bd7c5-myproject.aivencloud.com has address 35.228.157.197

Kafka topic-level metrics availability

Some Kafka topic-level JMX metrics might not be available if the topic has no recent traffic. For example:

  • Messages in per second: kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=<topic>
  • Replication bytes in per second: kafka.server:type=BrokerTopicMetrics,name=ReplicationBytesInPerSec

Kafka stops exposing these metrics after several minutes (typically 10 to 15) without message production or consumption on the topic. When traffic resumes, the metrics typically reappear after a short delay.

If you request one of these metrics while the topic is inactive, Jolokia returns a 404 response. This behavior is expected and does not indicate an issue with Kafka or Jolokia.

For more information, see the Kafka JMX documentation.

Example cURL requests

Before sending a cURL request, download the CA certificate for your project. The same certificate applies to all endpoints and services within the project.

To read a specific metric, use port 6733, which is the default port for Jolokia. Replace joljkr2l:PWD with the username and password generated during the Jolokia endpoint setup. View the credentials in the endpoint details on the Integration endpoints page.

curl --cacert ca.pem \
-X POST \
https://joljkr2l:PWD@HOST_IP:6733/jolokia/ \
-d \
'{"type":"read","mbean":"kafka.server:type=ReplicaManager,name=PartitionCount"}'

Jolokia supports searching beans using search command:

curl --cacert ca.pem \
-X POST \
https://joljkr2l:PWD@HOST_IP:6733/jolokia/ \
-d \
'{"type":"search","mbean":"kafka.server:*"}'