Skip to content

feat(mqtt): metrics and observability (Dropwizard / Prometheus) #608

Description

@mkjsix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions