Mosquitto Metrics Exporter
Pro Mosquitto provides a Prometheus exporter and a InfluxDB exporter which both expose the metrics available in the core broker and any metrics provided by other plugins.
Plugin configuration
Prometheus Metrics Exporter
To enable the Prometheus Metrics Exporter plugin it must be loaded into the broker with, by adding the
following to your mosquitto.conf
:
global_plugin /usr/lib/cedalo_metrics_prometheus.so
The plugin has some options which can be configured.
bind_address
: by default, the exporter will listen on all available network interfaces. You can bind it to a specific address using this option. For example,plugin_opt_bind_address 192.0.2.1
port
: by default, the exporter will listen on port 8000. You can use another port with this option. For exampleplugin_opt_port 8100
update_interval
: metrics stored in the exporter are updated on a set interval, by default 15 seconds. It is important to match this to the scrape interval of your Prometheus setup. If you are using a 60 second scrape interval, then useplugin_opt_update_interval 60
A sample configuration could look like:
global_plugin /usr/lib/cedalo_metrics_prometheus.so
plugin_opt_update_interval 60
plugin_opt_bind_address 192.0.2.1
plugin_opt_port 8100
InfluxDB Metrics Exporter
To enable the InfluxDB Metrics Exporter plugin it must be loaded into the broker with, by adding the
following to your mosquitto.conf
:
global_plugin /usr/lib/cedalo_metrics_influxdb.so
The plugin has some options which can be configured.
hostname
: The InfluxDB hostname to connect to. Required.port
: The network port to use to connect to InfluxDB. Optional, defaults to 8086.username
: The username to use when connecting to InfluxDB. Required.password
: The password to use when connecting to InfluxDB (i.e., the authorization token for the specified user). Required.database
: The InfluxDB database to send metrics to. Required.use_tls
: Set to true/false to use TLS encrypted connections. It is recommended to always use encrypted connections. Optional, defaults to false.cafile
: If you need to use a custom CA certificate for connecting to your InfluxDB instance, use this option to specify the file to use.hostlabel
: By default, the plugin will attempt to read the hostname of the instance where it is running, and set the host tag label to that value. This option allows you to specify a different label.measurement
: By default, themosquitto
measurement will be used for storing metrics. This option allows you to specify a different label.update_interval
: metrics stored in the exporter are published on a set interval, by default 15 seconds.connect_timeout
: Number of seconds to wait when connecting to InfluxDB, in case of failure. Optional, defaults to 10 seconds.
A sample configuration could look like:
global_plugin /usr/lib/cedalo_metrics_influxdb.so
plugin_opt_update_interval 60
plugin_opt_hostname influxdb.example.com
plugin_opt_port 8100
plugin_opt_hostlabel broker1
plugin_opt_database edge_data
plugin_opt_use_tls true
plugin_opt_username username
plugin_opt_password password
Optional configuration (applies to both exporters)
You may also consider turning off the $SYS updates from the broker:
sys_interval 0
Available metrics
label | metric type | description |
---|---|---|
mosquitto_sessions | Gauge | Current client sessions (includes offline clients) |
mosquitto_clients_offline | Gauge | Current offline client count |
mosquitto_clients_online | Gauge | Current online client count |
mosquitto_clients_expired | Counter | Total clients expired due to keepalive |
mosquitto_subscriptions | Gauge | Current subscription count |
mosquitto_shared_subscriptions | Gauge | Current shared subscription count |
mosquitto_retained_messages | Gauge | Current retained message count |
mosquitto_bytes_received | Counter | Total bytes received |
mosquitto_bytes_sent | Counter | Total bytes sent |
mosquitto_pub_bytes_received | Counter | Total PUBLISH payload bytes received |
mosquitto_pub_bytes_sent | Counter | Total PUBLISH payload bytes sent |
mosquitto_message_store_count | Gauge | Current stored message count |
mosquitto_message_store_bytes | Gauge | Current stored message bytes |
mosquitto_out_packets | Gauge | Current queued outgoing packet count (includes offline clients) |
mosquitto_out_packet_bytes | Gauge | Current queued outgoing packet bytes (includes offline clients) |
mosquitto_socket_connections | Counter | Total incoming connections |
mosquitto_mqtt_packets_received | Counter | Total MQTT packets received |
mosquitto_mqtt_packets_sent | Counter | Total MQTT packets sent |
mosquitto_mqtt_connect_received | Counter | MQTT CONNECT received |
mosquitto_mqtt_connect_sent | Counter | MQTT CONNECT sent |
mosquitto_mqtt_connack_received | Counter | MQTT CONNACK received |
mosquitto_mqtt_connack_sent | Counter | MQTT CONNACK sent |
mosquitto_mqtt_publish_dropped | Counter | MQTT PUBLISH dropped |
mosquitto_mqtt_publish_received | Counter | MQTT PUBLISH received |
mosquitto_mqtt_publish_sent | Counter | MQTT PUBLISH sent |
mosquitto_mqtt_puback_received | Counter | MQTT PUBACK received |
mosquitto_mqtt_puback_sent | Counter | MQTT PUBACK sent |
mosquitto_mqtt_pubrec_received | Counter | MQTT PUBREC received |
mosquitto_mqtt_pubrec_sent | Counter | MQTT PUBREC sent |
mosquitto_mqtt_pubrel_received | Counter | MQTT PUBREL received |
mosquitto_mqtt_pubrel_sent | Counter | MQTT PUBREL sent |
mosquitto_mqtt_pubcomp_received | Counter | MQTT PUBCOMP received |
mosquitto_mqtt_pubcomp_sent | Counter | MQTT PUBCOMP sent |
mosquitto_mqtt_subscribe_received | Counter | MQTT SUBSCRIBE received |
mosquitto_mqtt_subscribe_sent | Counter | MQTT SUBSCRIBE sent |
mosquitto_mqtt_suback_received | Counter | MQTT SUBACK received |
mosquitto_mqtt_suback_sent | Counter | MQTT SUBACK sent |
mosquitto_mqtt_unsubscribe_received | Counter | MQTT UNSUBSCRIBE received |
mosquitto_mqtt_unsubscribe_sent | Counter | MQTT UNSUBSCRIBE sent |
mosquitto_mqtt_unsuback_received | Counter | MQTT UNSUBACK received |
mosquitto_mqtt_unsuback_sent | Counter | MQTT UNSUBACK sent |
mosquitto_mqtt_pingreq_received | Counter | MQTT PINGREQ received |
mosquitto_mqtt_pingreq_sent | Counter | MQTT PINGREQ sent |
mosquitto_mqtt_pingresp_received | Counter | MQTT PINGRESP received |
mosquitto_mqtt_pingresp_sent | Counter | MQTT PINGRESP sent |
mosquitto_mqtt_disconnect_received | Counter | MQTT DISCONNECT received |
mosquitto_mqtt_disconnect_sent | Counter | MQTT DISCONNECT sent |
mosquitto_mqtt_auth_received | Counter | MQTT AUTH received |
mosquitto_mqtt_auth_sent | Counter | MQTT AUTH sent |
mosquitto_basic_auth_success | Counter | Successful username/password authentication attempts |
mosquitto_basic_auth_fail | Counter | Failed username/password authentication attempts |
mosquitto_basic_auth_error | Counter | Errored username/password authentication attempts |
mosquitto_extended_auth_success | Counter | Successful extended authentication attempts |
mosquitto_extended_auth_fail | Counter | Failed extended authentication attempts |
mosquitto_extended_auth_error | Counter | Errored extended authentication attempts |
Additional broker process related metrics
The broker process related metrics are exported by the Prometheus exporter only.
label | metric type | description |
---|---|---|
process_max_fds | Gauge | Maximum number of allowed open file descriptors (including network sockets). |
process_virtual_memory_max_bytes | Gauge | Maximum amount of virtual memory available in bytes |
process_cpu_seconds_total | Gauge | Total user and system CPU time spent in seconds. |
process_virtual_memory_bytes | Gauge | Virtual memory size in bytes. |
process_resident_memory_bytes | Gauge | Resident memory size in bytes. |
process_start_time_seconds | Gauge | Start time of the process since unix epoch in seconds. |
process_open_fds | Gauge | Number of open file descriptors (including network sockets). |