2

I have a Vernemq broker running in a docker container,and I want to know the number of active clients at a given point of time.I am currently using the $SYS/broker/queue/processes topic to get the active processes, but I am not sure if this is the right metric to get the number of connected clients. I have gone through the mqtt SYS topics, and it says that I can get the number of currently connected clients with $SYS/broker/clients/connected topic.However, I don't see any messages when I subscribe to that topic. Does Vernemq need any configuration changes to get the connected clients?Or is there any other metric which I can use for the same?

The docker compose file looks like this

container_name:
    image: vernemq/vernemq:1.10.2-1
    environment:
      DOCKER_VERNEMQ_LOG__CONSOLE: 'console'
      DOCKER_VERNEMQ_LOG__CONSOLE__LEVEL: 'debug'
      DOCKER_VERNEMQ_ALLOW_ANONYMOUS: 'on'
      DOCKER_VERNEMQ_SYSTREE_INTERVAL: '5000'

Thanks.

user3615045
  • 193
  • 2
  • 13

1 Answers1

0

AFAIK VerneMQ doesn't have a direct metric for the number of MQTT clients, but you should be able to subtract the socket_close metrics from the socket_open metric to get the number of currently connected clients. These metrics should also be available via $SYS as well. See also https://docs.vernemq.com/monitoring/introduction for more information about which metrics are available.

Note you can also go to the status page for a quick overview of the number of connected clients and overall cluster status: https://docs.vernemq.com/monitoring/status

Note the $SYS topic is not in the MQTT spec, so different brokers implement it differently - as you've already found out ;)