Monitoring MQTT Brokers

An MQTT broker severs as a hub for all MQTT messages and so it is important that it is always online and if not that you are ware of this.

There are several ways of monitoring the broker.

  • Using the Ping Command
  • Using the $SYS topic
  • Sending messages through it.
  • Monitoring Connection Status

Using the Ping Command

This very easy to implement as all machines support the ping command.

The ping command can be run manually or automatically.

The problem with it is that it doesn’t really monitor the MQTT broker but the machine that it is running on.

So if you were relying on this method if someone stopped the broker the pin command will not detect it as the machine is still up.


Using the $SYS Topic

Almost all broker publish broker statistics on the $SYS topic.

These are usually published at 5 second intervals but with the retain flag set.

If the broker is goes down then no statistics are published and so you will need to detect this.

Because only changes are published you need to monitor a topic that changes frequently.

However the $SYS topic can be disabled and so will not be available.


Flow Download


Sending and Receiving Messages

This IMO is the better method as you can monitor multiple instances separately.

Many MQTT brokers run MQTT over multiple ports to support SSL and Websockets.

In addition MQTT hosting providers run multiple instances of MQTT on a single machine.

A broker can be running

  • Plain MQTT
  • MQTT over SSL
  • MQTT over websockets
  • MQTT over websockets with SSL
  • MQTT on Other Ports

The technique is to send a message to each instance and to monitor the received message.


Monitoring Connection Status

I added this method after posting a video on monitoring.

All clients will report a connection failure and so you can use this to trigger an alert.

However personally I haven’t found this method fool proof which is why I didn’t include it initially. It is however probably the easiest to implement.


Node-Red MQTT Broker Monitor Using Ping

Monitor MQTT Broker Status and Delay Using Node-Red

Flow Download



Related Tutorials and Resources:


Please rate? And use Comments to let me know more

Leave a Reply

Your email address will not be published. Required fields are marked *