Skip to content

RocketMQ (Prometheus)

Apache RocketMQ is a distributed messaging and stream processing platform for decoupling services, smoothing traffic peaks, and event-driven applications.

See the official RocketMQ metrics documentation for supported versions. For environments using a standalone Exporter, see RocketMQ Integration.

Configuration

Prerequisites

  • A running RocketMQ Broker, version 5.1.0 or later.
  • Access to edit the configuration file actually loaded by the Broker and restart the service. In a cluster, enable the metrics endpoint on every Broker you plan to monitor.
  • DataKit can access the metrics port of each Broker. This guide uses the default port 5557.
  • A Topic, consumer group, and production/consumption traffic for verification. Without application traffic, some metrics may be zero or have no corresponding series.

Enable the built-in Prometheus metrics on the Broker

Edit the configuration file actually specified by the Broker startup argument -c, usually broker.conf, and add:

metricsExporterType=PROM
metricsPromExporterHost=0.0.0.0
metricsPromExporterPort=5557

After saving, restart the corresponding Broker using your existing deployment procedure; perform rolling restarts in production clusters according to your maintenance process. Then verify the metrics endpoint on the Broker host:

curl -fsS http://127.0.0.1:5557/metrics

The response should contain metrics prefixed with rocketmq_ and their type information. Also verify endpoint accessibility from the DataKit host using the actual Broker address.

metricsPromExporterHost=0.0.0.0 listens on all network interfaces. Restrict access with security groups or a firewall. For Docker deployments, map the container port 5557 to a host port accessible to DataKit. If DataKit also runs in a container, its 127.0.0.1 refers to the DataKit container itself.

Configure the Prom collector

Copy the sample Prom collector configuration on the DataKit host:

mkdir -p /usr/local/datakit/conf.d/prom
cp /usr/local/datakit/conf.d/samples/prom.conf.sample \
  /usr/local/datakit/conf.d/prom/rocketmq.conf

Edit rocketmq.conf and replace its contents with:

[[inputs.prom]]
  urls = ["http://127.0.0.1:5557/metrics"]
  ignore_req_err = false
  source = "rocketmq"
  # An empty list collects all metric types, including Counter, Gauge, and Histogram
  metric_types = []
  metric_name_filter = ["^rocketmq_"]
  interval = "10s"
  measurement_prefix = ""
  measurement_name = "rocketmq"
  # Preserve the full Prometheus metric field names
  keep_exist_metric_name = true
Parameter Description
urls Broker metrics endpoint addresses. 127.0.0.1 only applies when DataKit and the Broker run on the same host or share a network namespace.
ignore_req_err Set to false to retain metrics endpoint request errors for troubleshooting collection problems.
source Collector alias used to distinguish collection configurations in DataKit.
metric_types An empty list collects all metric types to avoid missing Histogram metrics.
metric_name_filter Collect only metrics prefixed with rocketmq_.
interval Collection interval, set to 10s in this guide.
measurement_prefix Measurement prefix, set to an empty string in this guide.
measurement_name Write all collected metrics to the rocketmq measurement.
keep_exist_metric_name Set to true to preserve the full Prometheus metric field names.

See the Prom collector documentation for more parameters.

For cluster deployments, replace urls in the configuration with the actual metrics addresses of the Brokers:

urls = [
  "http://<BROKER_1_IP>:5557/metrics",
  "http://<BROKER_2_IP>:5557/metrics"
]

Alternatively, deploy DataKit on each Broker host and collect the local endpoint. Choose one coverage method to avoid collecting the same endpoint twice.

After saving the configuration, restart DataKit to apply it:

datakit service restart

Verify collection results

Use the Prom configuration debug command to inspect the converted measurement, fields, and tags:

datakit debug --prom-conf /usr/local/datakit/conf.d/prom/rocketmq.conf

The debug output should include the rocketmq measurement and fields prefixed with rocketmq_. Use the following command to check collector status and request errors:

datakit monitor

Metrics

With this configuration, metrics are written to the rocketmq measurement and fields retain their full Prometheus names. The fields actually available depend on the Broker /metrics endpoint, DataKit debug output, and ingested data.

Metric Description Type Unit
rocketmq_messages_in_total Cumulative messages received by the Broker. Calculate the per-second rate to observe production TPS. Counter messages
rocketmq_messages_out_total Cumulative messages delivered by the Broker to consumers. Calculate the per-second rate to observe consumption TPS. Counter messages
rocketmq_throughput_in_total Cumulative bytes written to the Broker by producers. Calculate the per-second rate to obtain write throughput. Counter Byte
rocketmq_throughput_out_total Cumulative bytes read from the Broker by consumers. Calculate the per-second rate to obtain read throughput. Counter Byte
rocketmq_consumer_ready_messages Ready messages for the Topic and consumer group that have not been pulled and are waiting for consumption. Gauge messages
rocketmq_consumer_inflight_messages Messages for the Topic and consumer group that have been pulled but not yet acknowledged as complete. Gauge messages
rocketmq_consumer_lag_latency_milliseconds Difference between the current time and the consumable time of the earliest unacknowledged message, reflecting how promptly consumption completes. Gauge milliseconds
rocketmq_storage_flush_behind_bytes Broker data not yet flushed to disk. Gauge Byte
rocketmq_message_size Distribution of sent message sizes. Calculate P95 using its histogram buckets. Histogram Byte
rocketmq_rpc_latency_milliseconds Distribution of Broker RPC latency. Observe P95 for send and pull requests by request type. Histogram milliseconds

The official RocketMQ logical metrics rocketmq_consumer_lag_latency and rocketmq_rpc_latency have the unit suffix _milliseconds in this example. Histogram metrics expand into _bucket, _sum, and _count, such as rocketmq_rpc_latency_milliseconds_bucket. Check the actual fields and units before creating views and monitors.

Counters are cumulative values and cannot directly represent TPS or per-second throughput. After calculating the per-second rate, message counts use messages/s and byte counts use Byte/s. Gauges represent the current state; observe the values and trends of ready messages, inflight messages, and consumer lag directly. Consumer lag is the waiting time of the earliest unacknowledged message, rather than the average processing time of completed messages.

Common tags

Tag Description
cluster RocketMQ cluster name.
node_id Broker node identifier.
topic Topic name, used to distinguish production and consumption by topic.
consumer_group Consumer group identifier, used to locate backlog and consumer lag.

Tags vary by metric; use the actual collected data as the reference. Broker storage metrics are usually viewed by cluster and node_id, while consumer group metrics can be viewed by cluster, topic, and consumer_group.

Feedback

Is this page helpful?