Sub-issue of #601.
Summary
Integrate the mqtt module with RESTHeart's existing metrics module to expose MQTT ingestion health via Dropwizard Metrics and the Prometheus /metrics endpoint.
Motivation
Without metrics, operators have no visibility into whether the MQTT bridge is healthy, whether messages are being dropped, or whether the MongoDB write buffer is near capacity. This is essential for production deployments.
Proposed metrics
| Metric |
Type |
Description |
mqtt.messages.received |
Meter |
Messages received from broker per topic |
mqtt.messages.dropped.rate-limit |
Meter |
Messages dropped by global router rate limiter |
mqtt.messages.dropped.queue-full |
Meter |
Messages dropped due to full per-connection SSE queue |
mqtt.pipeline.dropped |
Meter |
Messages discarded by pipeline stages (per stage type) |
mqtt.buffer.size |
Gauge |
Current MongoDB write buffer fill level (0–capacity) |
mqtt.buffer.dropped |
Meter |
Messages dropped by write buffer overflow |
mqtt.writer.batch-latency |
Timer |
Time from message receipt to MongoDB insert |
mqtt.writer.dead-letter.count |
Counter |
Cumulative failed batches written to dead-letter |
mqtt.broker.connected |
Gauge |
1 = connected, 0 = disconnected |
mqtt.broker.reconnects |
Counter |
Cumulative broker reconnect attempts |
All metrics are tagged with the topic filter where applicable.
Scope
MqttMetrics singleton initialized by MqttClientProvider at startup.
- Injected (not via
@Inject — internal singleton) into MqttMessageRouter, MqttSseService, and MqttMongoWriter.
- Metrics registered with RESTHeart's
MetricRegistry using the mqtt. namespace.
- Health check:
mqtt.broker.connected == 0 marks the /health endpoint as degraded.
Dependencies
Sub-issue of #601.
Summary
Integrate the
mqttmodule with RESTHeart's existingmetricsmodule to expose MQTT ingestion health via Dropwizard Metrics and the Prometheus/metricsendpoint.Motivation
Without metrics, operators have no visibility into whether the MQTT bridge is healthy, whether messages are being dropped, or whether the MongoDB write buffer is near capacity. This is essential for production deployments.
Proposed metrics
mqtt.messages.receivedmqtt.messages.dropped.rate-limitmqtt.messages.dropped.queue-fullmqtt.pipeline.droppedmqtt.buffer.sizemqtt.buffer.droppedmqtt.writer.batch-latencymqtt.writer.dead-letter.countmqtt.broker.connectedmqtt.broker.reconnectsAll metrics are tagged with the topic filter where applicable.
Scope
MqttMetricssingleton initialized byMqttClientProviderat startup.@Inject— internal singleton) intoMqttMessageRouter,MqttSseService, andMqttMongoWriter.MetricRegistryusing themqtt.namespace.mqtt.broker.connected == 0marks the/healthendpoint as degraded.Dependencies
metricsmodule to be enabled.