JmxTool Standalone Application

kafka.tools.JmxTool is a standalone application to print JMX metrics of a given endpoint (e.g. Kafka broker) to standard output every reporting-interval (unless one-time option is specified).

JmxTool can be executed using kafka-run-class shell script.

./bin/kafka-run-class.sh kafka.tools.JmxTool \
  --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec
Trying to connect to JMX url: service:jmx:rmi:///jndi/rmi://:9999/jmxrmi.
"time","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:Count","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:EventType","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:FifteenMinuteRate","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:FiveMinuteRate","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:MeanRate","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:OneMinuteRate","kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec:RateUnit"
1567588157489,0,messages,0.0,0.0,0.0,0.0,SECONDS
1567588159492,0,messages,0.0,0.0,0.0,0.0,SECONDS
1567588161494,0,messages,0.0,0.0,0.0,0.0,SECONDS
^C
Tip

Enable remote JMX of a Kafka broker using JMX_PORT environment variable when starting it with ./bin/kafka-server-start.sh, e.g.

JMX_PORT=9999 ./bin/kafka-server-start.sh config/server.properties

When executed with no options, JmxTool assumes --help.

Table 1. Options
Option Description

attributes

The comma-separated whitelist of attributes to query.

If no attributes are specified all objects will be queried.

date-format

Date format to use for formatting the time field.

See java.text.SimpleDateFormat for options.

help

Prints usage information

jmx-auth-prop

Mechanism to pass property in the form 'username=password' when enabling remote JMX with password authentication

jmx-ssl-enable

Flag to enable remote JMX with SSL

Default: false

jmx-url

URL to connect to poll JMX data

Default: service:jmx:rmi:///jndi/rmi://:9999/jmxrmi

object-name

A JMX object name to use as a query.

This can contain wildcards, and can be given multiple times to specify more than one query.

If no objects are specified all objects will be queried.

one-time

Flag to indicate run once only

Default: false

report-format

Output format name.

Default: original

One of the following:

  • original

  • properties

  • csv

  • tsv

reporting-interval

Interval (in millis) to poll jmx stats with

Default: 2000 (2 seconds)

-1 is equivalent to one-time

wait

Wait for requested JMX objects to become available before starting output. Only supported when the list of objects is non-empty and contains no object name patterns.

Executing Standalone Application — main Method

main(args: Array[String]): Unit

main is the entry point of the JmxTool standalone application when launched on command line (e.g. from bin/kafka-configs.sh).

Internally, main reads the options from the command line.

main prints out the following to standard error:

Trying to connect to JMX url: [url].

main…​FIXME

results matching ""

    No results matching ""