HiveMQ Edge Monitoring
The ability to monitor server applications is very important for operating these applications. HiveMQ is no exception, in fact HiveMQ was designed to enable different kinds of monitoring easily. When using HiveMQ in critical infrastructure, we strongly recommended to enable monitoring and use a decent application for displaying the relevant information you need for your operations.
Gathering metrics is enabled by default. The HiveMQ metrics subsystem is designed to be very performant and no performance penalties are expected for monitoring relevant metrics, even in low-latency and high-throughput environments.
JMX
HiveMQ has extensive support for Java Management Extensions (JMX) to monitor internals of HiveMQ and the JVM. JMX is a proven industry standard for Java Monitoring and many external tools support JMX natively or via extensions.
Turn on JMX
To turn on remote JMX, set the JMX properties in the JAVA_OPTS environment variable before you start HiveMQ Edge.
The start scripts run.sh and run.bat add the content of JAVA_OPTS to the Java command line.
Remote JMX must use authentication and should use TLS:
export JAVA_OPTS="$JAVA_OPTS \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.password.file=/opt/hivemq/conf/jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=/opt/hivemq/conf/jmxremote.access \
-Dcom.sun.management.jmxremote.ssl=true \
-Djavax.net.ssl.keyStore=/opt/hivemq/conf/jmx-keystore.jks \
-Djavax.net.ssl.keyStorePassword=<KEYSTORE_PASSWORD>"
The password file holds the user names and passwords, and the access file grants each user readonly or readwrite access.
The password file must be readable only by the user that runs HiveMQ Edge; otherwise, the Java Virtual Machine refuses to start JMX.
For the format of both files and for all other JMX properties, see the Java documentation on monitoring and management with JMX.
The TLS certificate in the keystore must name the host that JMX clients connect to: the host name or IP address of the HiveMQ Edge host, or, behind Docker or NAT, the address set in java.rmi.server.hostname.
JMX clients refuse a certificate without a matching name, such as one that a plain keytool -genkeypair creates.
To add the name, pass -ext SAN=dns:<HOST> or -ext SAN=ip:<IP_ADDRESS> to keytool -genkeypair.
On Windows, set the JAVA_OPTS environment variable with the same properties before you run run.bat.
Turn on JMX in Docker
The HiveMQ Edge Docker image sets JAVA_OPTS to -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA.
When you set JAVA_OPTS for the container, you replace this value, so include both options together with the JMX properties.
Mount the password file, the access file, and the keystore into the container, and publish the JMX port:
docker run \
-p 9010:9010 \
-v /path/to/jmx:/opt/hivemq/conf/jmx \
-e JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.rmi.port=9010 \
-Djava.rmi.server.hostname=<PUBLIC_IP> \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.password.file=/opt/hivemq/conf/jmx/jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=/opt/hivemq/conf/jmx/jmxremote.access \
-Dcom.sun.management.jmxremote.ssl=true \
-Djavax.net.ssl.keyStore=/opt/hivemq/conf/jmx/jmx-keystore.jks \
-Djavax.net.ssl.keyStorePassword=<KEYSTORE_PASSWORD>" \
hivemq/hivemq-edge
A published container port is a form of Network Address Translation (NAT), so the example also sets the two NAT options from the next section.
JMX behind NAT
If you run HiveMQ Edge behind a Network Address Translation (NAT) process, you must also set these options:
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=<PUBLIC_IP>" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.rmi.port=9010"
This allows you to connect via JConsole using PUBLIC_IP:9010.
MBeans
When JMX is activated, the following MBeans can be used for monitoring:
| MBean Name | Description |
|---|---|
|
The HiveMQ metrics and statistics. A list of all available metrics is available here. |
|
Statistics and metrics about used native memory. |
|
All information about the Java Virtual Machine can be monitored here. |
HiveMQ Edge Available Metrics
Metric Types
HiveMQ Edge provides five different types of metrics:
| Metric Type | Description |
|---|---|
|
A gauge returns a simple value at the point of time the metric was requested. |
|
A counter is a simple incrementing and decrementing number. |
|
A histogram measures the distribution of values in a stream of data. They allow to measure min, mean, max, standard deviation of values and quantiles. |
|
A meter measures the rate at which a set of events occur. Meters measure mean, 1-, 5-, and 15-minute moving averages of events. |
|
A timer is basically a histogram of the duration of a type of event and a meter of the rate of its occurrence. It captures rate and duration information. |
The following table lists metrics that are available for monitoring HiveMQ Edge:
| Metric | Type | Description |
|---|---|---|
com.hivemq.edge.messages.dropped.count |
|
Counts every dropped message |
com.hivemq.edge.messages.incoming.connect.count |
|
Counts every incoming MQTT CONNECT message |
com.hivemq.edge.messages.incoming.publish.count |
|
Counts every incoming MQTT PUBLISH message |
com.hivemq.edge.messages.incoming.total.count |
|
Counts every incoming MQTT message |
com.hivemq.edge.messages.outgoing.publish.count |
|
Counts every outgoing MQTT PUBLISH message |
com.hivemq.edge.messages.outgoing.total.count |
|
Counts every outgoing MQTT message |
com.hivemq.edge.messages.retained.current |
|
The current amount of retained messages |
com.hivemq.edge.messages.will.count.current |
|
The current number of stored Last Will messages. |
com.hivemq.edge.messages.will.published.count.total |
|
The total number of published Last Will messages. |
com.hivemq.edge.mqtt.connections.not-writable.current |
|
Counts the number of MQTT client channels which are currently not writable |
com.hivemq.edge.mqtt.incoming.qos2-flows.current |
|
The current number of inbound QoS 2 messages of all clients that wait for a PUBREL. The |
com.hivemq.edge.networking.bytes.read.total |
|
The total amount of read bytes |
com.hivemq.edge.networking.bytes.write.total |
|
The total amount of written bytes |
com.hivemq.edge.networking.connections.current |
|
The current number of active MQTT connections |
com.hivemq.edge.networking.connections-closed.total.count |
|
The total number of clients that disconnected gracefully and ungracefully from HiveMQ |
com.hivemq.edge.sessions.overall.current |
|
Measures the current count of stored sessions. These sessions include all sessions, including online and offline clients |
com.hivemq.edge.subscriptions.overall.current |
|
Measures the current count of subscriptions on the broker |
com.hivemq.edge.persistence.client-sessions.in-memory.total-size |
|
Measures the approximate memory usage of the client session persistence if the memory persistence is used |
com.hivemq.edge.persistence.client-session.subscriptions.in-memory.total-size |
|
Measures the approximate memory usage of the subscription persistence if the memory persistence is used. |
com.hivemq.edge.persistence.retained-messages.in-memory.total-size |
|
Measures the approximate memory usage of the retained message persistence if the memory persistence is used |
com.hivemq.edge.persistence.payload.in-memory.total-size |
|
Measures the approximate memory usage of the payload persistence if the memory persistence is used |
com.hivemq.edge.persistence.queued-messages.in-memory.total-size |
|
Measures the approximate memory usage of the queued message persistence if the memory persistence is used |
com.hivemq.edge.license-till-expire |
|
Time in days until the installed license expires |
Monitoring via Extensions
HiveMQ Edge provides capabilities to extend functionality via the HiveMQ Extension SDK. There are extensions available that allow integration with third-party tools to export metrics into these systems.
For more information, see HiveMQ Platform Monitoring.