Integrate a self-hosted RocketMQ instance

Updated at:

This topic describes how to connect a self-managed RocketMQ instance to Cloud Monitor 2.0. The integration component is based on the RocketMQ adapter for aio-exporter and uses a remoting management interface to collect metrics such as Broker runtime, Topic/consumer group message accumulation, production and consumption TPS, and online consumer clients. This solution supports RocketMQ 4.3.2 or later (4.9.x is recommended) and deployment on ACK clusters or on Elastic Compute Service (ECS) instances in a virtual private cloud (VPC). Once integrated, RocketMQ instance entities and a built-in dashboard are automatically generated.

Note

Collection scheduling (v1.0-9d3c2c2 and later): The Exporter schedules RPC collection independently for each task in the background. This feature is enabled by default and is decoupled from the Prometheus scrape of /metrics. The Metric Collection Interval parameter in the form controls only the Prometheus scrape frequency. You can separately configure the collection cycle, concurrency, and traffic-smoothing parameters of each task to reduce the CPU impact on brokers in large clusters.

Requirements

Before you start the integration, make sure that the target instance meets the following requirements. Otherwise, no data may be collected or some metrics may be missing.

Condition

Requirement

Version

RocketMQ 4.3.2 or later. Version 4.9.x is recommended. Version 5.x must run in remoting mode. End-to-end functionality was verified using version 5.3.1.

Deployment type

Only self-managed RocketMQ is supported. Alibaba Cloud ApsaraMQ for RocketMQ provides only SDK endpoints and does not expose remoting management interfaces. Use the cloud-acs-rocketmq cloud product plugin instead.

Collection method

Connect to the NameServer (default port: 9876) to pull routes. Then, connect directly to the remoting port of each broker (default port: 10911). All broker nodes must be reachable.

Broker registration address

The broker registers with the NameServer using brokerIP1, which must be an address that is routable by the Exporter. If containers, Network Address Translation (NAT), or cross-CIDR block access is not configured, only topic metadata can be collected, and broker runtime metrics will be empty.

ACL

If aclEnable is enabled on the broker, provide an AccessKey and SecretKey for an account with management permissions. If ACL is disabled, leave these fields empty.

Network connectivity

For CS environments, the NameServer and all brokers must be connectable within the selected ACK cluster network. For ECS (VPC) environments, the vSwitch CIDR block for the managed agent must have access to these nodes.

Prerequisites

  • You have activated Managed Service for Prometheus.

  • For CS environments, the target ACK cluster is connected to Cloud Monitor 2.0 and is running, and the target RocketMQ service is accessible from the cluster network.

  • For ECS (VPC) environments, an ECS instance is selected to host the target RocketMQ service, and the vSwitch CIDR block of the managed agent can access the ECS instance.

Billing

  • Billing is based solely on the volume of metric data generated in Billing overview.

Integration methods

Step 1: Confirm the ACL (if needed)

Skip this step if Access Control List (ACL) is not enabled for the broker (aclEnable). If ACL is enabled, obtain an AccessKey and SecretKey with management permissions and enter them in the integration form.

ApsaraMQ for RocketMQ cannot use this plugin. Install cloud-acs-rocketmq instead.

Step 2: Select an integration environment

This plugin supports two integration environments: CS and ECS (VPC). They work differently. Select an environment based on where your RocketMQ service is deployed:

CS

  • Installs the Exporter in a target ACK cluster that you specify. It reuses the cluster's existing data collector to collect metrics.

  • The monitored object is the ACK cluster.

  • Network requirements: The target RocketMQ service must be accessible from within the cluster network. For example, a service within the cluster or a private IP address in a VPC that the cluster can access.

ECS (VPC)

  • The system deploys a fully managed data collector based on the VPC information of the ECS instance that you select. This instance is where your target RocketMQ service is deployed.

  • No processes are installed on the ECS instance.

  • The monitored object is the ECS instance.

  • Network requirements: The vSwitch CIDR block of the managed agent must allow access to the target ECS instance. Configure security groups and ACLs to permit this traffic.

Environment

Exporter deployment location

Installs process on service machine?

Monitored object

Network accessibility requirements

CS

In a specified ACK cluster

No. Deployed in the cluster, not on the host of the application Pod.

ACK cluster

RocketMQ is accessible from the cluster network.

ECS (VPC)

In a fully managed data collector deployed by the system based on the VPC.

No. No processes are installed on the ECS instance.

ECS instance

The vSwitch CIDR block of the managed agent can access the target ECS instance.

Step 3: Configure the integration

  1. Log on to the Cloud Monitor 2.0 console and select a workspace. In the navigation pane on the left, click Integration Center, and then click RocketMQ.

  2. Select an integration environment (CS or ECS (VPC)), and then select a Monitored Object from the drop-down list.

  3. Configure the integration settings and click OK:

    Basic settings

    Configuration item

    Required

    Default value

    Description

    RocketMQ NameServer Address

    Yes

    -

    The address in host:port or ip:port format. Use a semicolon (;) to separate multiple addresses.

    Cloud Vendor/Deployment Source

    No

    self-hosted/rocketmq

    The value is written to the provider tag. The options do not include the Alibaba Cloud managed version.

    AccessKey/SecretKey (ACL)

    No

    Empty

    Enter these credentials only if ACL is enabled on the broker.

    Metric Collection Interval (seconds)

    Yes

    30

    The interval at which Prometheus scrapes /metrics. If Schedule Collection Independently by Task is enabled, this parameter is no longer used as the cycle for full background RPC collection.

    Custom Tags

    No

    Empty

    Additional tags to add to the metrics.

    Use Public Registry Address

    No

    Disabled

    Enable this option if the private image repository is not accessible.

    Collection scheduling and concurrency (optional. For large clusters, we recommend that you use the default values.)

    Configuration item

    Required

    Default value

    Description

    Schedule Collection Independently by Task

    No

    Enabled

    If this option is enabled, background collection is scheduled independently for each task listed in the following section. If this option is disabled, collection falls back to a single collect_interval, which equals the metric collection interval.

    Topic/Consumer Group Collection Concurrency (workers)

    No

    1

    The RPC concurrency for topics and consumer groups. For large clusters, we recommend that you keep the value 1.

    Broker Collection Concurrency (broker_workers)

    No

    1

    The concurrency for broker-level collection, which includes runtime and stats metrics. For large clusters, we recommend that you keep the value 1.

    Metric Cache TTL (seconds)

    No

    0

    A value of 0 indicates the automatic mode, in which the TTL is twice the interval of each task. Specify a positive integer to use a fixed TTL.

    Client Metric Concurrency (client_metric_workers)

    No

    10

    The size of the thread pool that is used to asynchronously collect metrics of online consumer clients.

    Client Metric Queue Length

    No

    5000

    The capacity of the asynchronous task queue for client metrics.

    Collect Consumption Latency (storetime)

    No

    Enabled

    Specifies whether to collect rocketmq_group_get_latency_by_storetime. You can disable this option for large clusters to reduce RPC load.

    Topic Collection Interval (milliseconds)

    No

    0

    The sleep interval after each topic is processed. This parameter is used to smooth traffic peaks. For example, you can set it to a value from 50 to 200.

    Consumer Group Collection Interval (milliseconds)

    No

    0

    The sleep interval between consumer groups.

    Task scheduling cycles (effective only when Schedule Collection Independently by Task is enabled)

    The value can be a Go duration, such as 60s or 15m, or a Spring cron expression. Specify a hyphen (-) to disable the task.

    Configuration item

    Default value

    Description

    Task collect_topic_offset

    - (disabled)

    Collects topic offsets. This task is disabled by default to reduce RPC load.

    Task collect_producer

    120s

    Producer metrics.

    Task collect_consumer_offset

    15m

    Consumer group message accumulation and offsets. This task is relatively resource-intensive. For large clusters, we recommend a value of 15m or greater.

    Task collect_broker_stats_topic

    120s

    Per-topic broker stats. This is the most resource-intensive task. You can use it together with the topic collection interval to smooth traffic peaks.

    Task collect_broker_stats

    120s

    Aggregated broker stats.

    Task collect_broker_runtime_stats

    60s

    Broker runtime metrics, such as thread pools and TPS.

    Note

    Tuning recommendations for large clusters: Keep workers=1 and broker_workers=1. Increase the intervals of collect_broker_stats_topic and collect_consumer_offset first. If the queue of the query thread pool on a broker keeps growing, increase the interval of the corresponding task or set topic_sleep_millis to a value from 50 to 200.

  4. After the integration is successful, you can view the integrated entities and their observable data in Entity Explorer.

Data usage

Entities

After integration, Cloud Monitor periodically discovers RocketMQ instances using the labels of metrics such as rocketmq_broker_tps and creates middleware entities:

Dimension

Description

Domain

middleware

Entity type

middleware.rocketmq

Entity filter condition

.entity with(domain='middleware', type='middleware.rocketmq')

Monitored object (bound entity)

acs.ack.cluster for CS environments and acs.ecs.instance for ECS (VPC) environments

Entity fields are derived from collected labels and are independent of the number of installations:

Field

Description

instance_id

Instance identity. This is usually obtained from NameServer or cluster-related labels.

provider

Deployment source, such as self-hosted/rocketmq.

region_id

Region

env_type

Deployment environment type (CS or ECS).

cluster_id

Cluster identity

You can retrieve instances in the Entity Explorer or Middleware Insight application using the preceding fields.

Metrics related to online consumers depend on reports from online consumer clients. If all clients are offline, the corresponding metrics are empty.

Built-in dashboards

Dashboard Name

Access Point

Description

Instance Overview

The Instance Overview tab on the entity details page

A UModel dashboard. Variables are automatically bound based on the instance context.

RocketMQ Overview

Grafana dashboard list

A Grafana dashboard. Both Chinese and English versions are available.

Core metrics

The following is a complete list of the 89 metrics for the middleware.metric.rocketmq entity dataset. These metrics can be used directly in entity details, dashboards, and alerts:

Metric Name

Type

Unit

Display Name

Description

rocketmq_group_diff

gauge

-

Consumer group accumulation

The message accumulation of a consumer group. This is the difference between the latest offset and the consumer offset on the broker.

rocketmq_group_retrydiff

gauge

-

Consumer group retry accumulation

The message accumulation on the retry topic of a consumer group.

rocketmq_group_dlqdiff

gauge

-

Consumer group DLQ accumulation

The message accumulation on the dead-letter queue (DLQ) of a consumer group.

rocketmq_group_count

gauge

-

Number of consumer groups

The number of consumer groups, or the count related to consumer groups reported by the exporter.

rocketmq_producer_count

gauge

-

Number of producer instances

The number of connected producer instances for the current topic or group.

rocketmq_producer_offset

gauge

-

Producer offset

The producer (latest) offset for the current topic on the broker.

rocketmq_topic_retry_offset

gauge

-

Retry topic offset

The current offset of the topic's retry queue.

rocketmq_topic_dlq_offset

gauge

-

DLQ topic offset

The current offset of the topic's DLQ.

rocketmq_client_consume_fail_msg_count

gauge

-

Client consumption failures

The number of messages that the consumer client failed to consume.

rocketmq_client_consume_fail_msg_tps

gauge

ops/s

Client consumption failure TPS

The Transaction Per Second (TPS) of failed consumption attempts by the consumer client.

rocketmq_client_consume_ok_msg_tps

gauge

ops/s

Client consumption success TPS

The TPS of successful consumption attempts by the consumer client.

rocketmq_client_consume_rt

gauge

ms

Client consumption time

The client's consumption response time (RT) in milliseconds.

rocketmq_client_consumer_pull_rt

gauge

ms

Client pull time

The response time (RT) for the client to pull messages, in milliseconds.

rocketmq_client_consumer_pull_tps

gauge

ops/s

Client pull TPS

The TPS for the client to pull messages.

rocketmq_broker_tps

gauge

ops/s

Broker production TPS

The TPS for the broker to write (produce) messages.

rocketmq_broker_qps

gauge

ops/s

Broker pull QPS

The Queries Per Second (QPS) for the broker to read (consume and pull) messages.

rocketmq_broker_commitlog_diff

gauge

-

Broker CommitLog difference

The CommitLog offset difference at the broker level. Use this to observe primary-secondary synchronization lag.

rocketmq_brokeruntime_pmdt_0ms

gauge

-

Write time bucket 0 ms

The number of samples where the message write time falls into the 0 ms bucket.

rocketmq_brokeruntime_pmdt_0to10ms

gauge

-

Write time bucket 0–10 ms

The number of samples where the message write time falls into the 0–10 ms bucket.

rocketmq_brokeruntime_pmdt_10to50ms

gauge

-

Write time bucket 10–50 ms

The number of samples where the message write time falls into the 10–50 ms bucket.

rocketmq_brokeruntime_pmdt_50to100ms

gauge

-

Write time bucket 50–100 ms

The number of samples where the message write time falls into the 50–100 ms bucket.

rocketmq_brokeruntime_pmdt_100to200ms

gauge

-

Write time bucket 100–200 ms

The number of samples where the message write time falls into the 100–200 ms bucket.

rocketmq_brokeruntime_pmdt_200to500ms

gauge

-

Write time bucket 200–500 ms

The number of samples where the message write time falls into the 200–500 ms bucket.

rocketmq_brokeruntime_pmdt_500to1s

gauge

-

Write time bucket 500 ms–1 s

The number of samples where the message write time falls into the 500 ms–1 s bucket.

rocketmq_brokeruntime_pmdt_1to2s

gauge

-

Write time bucket 1–2 s

The number of samples where the message write time falls into the 1–2 s bucket.

rocketmq_brokeruntime_pmdt_2to3s

gauge

-

Write time bucket 2–3 s

The number of samples where the message write time falls into the 2–3 s bucket.

rocketmq_brokeruntime_pmdt_3to4s

gauge

-

Write time bucket 3–4 s

The number of samples where the message write time falls into the 3–4 s bucket.

rocketmq_brokeruntime_pmdt_4to5s

gauge

-

Write time bucket 4–5 s

The number of samples where the message write time falls into the 4–5 s bucket.

rocketmq_brokeruntime_pmdt_5to10s

gauge

-

Write time bucket 5–10 s

The number of samples where the message write time falls into the 5–10 s bucket.

rocketmq_brokeruntime_pmdt_10stomore

gauge

-

Write time bucket ≥10 s

The number of samples where the message write time falls into the ≥10 s bucket.

rocketmq_consumer_tps

gauge

ops/s

Consumption TPS

The TPS for consumer groups to pull messages from the broker.

rocketmq_group_consume_tps

gauge

ops/s

Consumer group consumption TPS

The consumption throughput (TPS) of the consumer group.

rocketmq_consumer_offset

gauge

-

Consumer offset

The current consumer offset of the consumer group on the broker.

rocketmq_group_consume_total_offset

gauge

-

Consumer group cumulative offset

The total consumer offset of the consumer group.

rocketmq_consumer_message_size

gauge

bytes

Consumed message size

The size of consumed messages in bytes.

rocketmq_send_back_nums

gauge

-

Number of sent-back messages

The number of messages sent back to the broker (due to consumption failure retries or rollbacks).

rocketmq_group_get_latency_by_storetime

gauge

ms

Consumption fetch latency

The consumption fetch latency calculated based on the storage timestamp, in milliseconds.

rocketmq_producer_tps

gauge

ops/s

Production TPS

The TPS for producing (writing) messages to the topic.

rocketmq_producer_message_size

gauge

bytes

Produced message size

The size of produced or written messages in bytes.

rocketmq_brokeruntime_msg_put_total_today_now

gauge

-

Total writes today so far

The total number of messages written today so far.

rocketmq_brokeruntime_msg_gettotal_today_now

gauge

-

Total reads today so far

The total number of messages read today so far.

rocketmq_brokeruntime_dispatch_behind_bytes

gauge

bytes

Dispatch lag in bytes

The number of bytes that the dispatch process has fallen behind (from CommitLog to ConsumeQueue).

rocketmq_brokeruntime_put_message_size_total

gauge

bytes

Total size of written messages

The total size of written messages in bytes.

rocketmq_brokeruntime_put_message_average_size

gauge

bytes

Average size of written messages

The average size of written messages in bytes.

rocketmq_brokeruntime_query_threadpool_queue_capacity

gauge

-

Query thread pool queue capacity

The queue capacity of the broker's query thread pool.

rocketmq_brokeruntime_remain_transientstore_buffer_numbs

gauge

-

Remaining TransientStore buffers

The number of remaining TransientStore buffers.

rocketmq_brokeruntime_earliest_message_timestamp

gauge

Time

Earliest message timestamp

The timestamp of the earliest message retained on the broker.

rocketmq_brokeruntime_putmessage_entire_time_max

gauge

ms

Max end-to-end write time

The maximum end-to-end time for writing a message, in milliseconds.

rocketmq_brokeruntime_start_accept_sendrequest_time

gauge

Time

Send request acceptance start time

The timestamp when the broker started accepting send requests.

rocketmq_brokeruntime_send_threadpool_queue_size

gauge

-

Send thread pool queue size

The current size of the broker's send thread pool queue.

rocketmq_brokeruntime_putmessage_times_total

gauge

-

Total number of message writes

The total number of message write operations.

rocketmq_brokeruntime_getmessage_entire_time_max

gauge

ms

Max end-to-end read time

The maximum end-to-end time for reading a message, in milliseconds.

rocketmq_brokeruntime_pagecache_lock_time_mills

gauge

ms

PageCache lock time

The time spent on PageCache locking, in milliseconds.

rocketmq_brokeruntime_commitlog_disk_ratio

gauge

%

CommitLog disk usage

The disk usage of the disk where the CommitLog is stored.

rocketmq_brokeruntime_consumequeue_disk_ratio

gauge

%

ConsumeQueue disk usage

The disk usage of the disk where the ConsumeQueue is stored.

rocketmq_brokeruntime_getfound_tps600

gauge

ops/s

Hit pull TPS (10 min)

The TPS of successful (found) pulls within a 600-second window.

rocketmq_brokeruntime_getfound_tps60

gauge

ops/s

Hit pull TPS (1 min)

The TPS of successful (found) pulls within a 60-second window.

rocketmq_brokeruntime_getfound_tps10

gauge

ops/s

Hit pull TPS (10 sec)

The TPS of successful (found) pulls within a 10-second window.

rocketmq_brokeruntime_gettotal_tps600

gauge

ops/s

Total pull TPS (10 min)

The total pull TPS within a 600-second window.

rocketmq_brokeruntime_gettotal_tps60

gauge

ops/s

Total pull TPS (1 min)

The total pull TPS within a 60-second window.

rocketmq_brokeruntime_gettotal_tps10

gauge

ops/s

Total pull TPS (10 sec)

The total pull TPS within a 10-second window.

rocketmq_brokeruntime_gettransfered_tps600

gauge

ops/s

Transferred pull TPS (10 min)

The TPS of transferred pulls within a 600-second window.

rocketmq_brokeruntime_gettransfered_tps60

gauge

ops/s

Transferred pull TPS (1 min)

The TPS of transferred pulls within a 60-second window.

rocketmq_brokeruntime_gettransfered_tps10

gauge

ops/s

Transferred pull TPS (10 sec)

The TPS of transferred pulls within a 10-second window.

rocketmq_brokeruntime_getmiss_tps600

gauge

ops/s

Missed pull TPS (10 min)

The TPS of missed pulls within a 600-second window.

rocketmq_brokeruntime_getmiss_tps60

gauge

ops/s

Missed pull TPS (1 min)

The TPS of missed pulls within a 60-second window.

rocketmq_brokeruntime_getmiss_tps10

gauge

ops/s

Missed pull TPS (10 sec)

The TPS of missed pulls within a 10-second window.

rocketmq_brokeruntime_put_tps600

gauge

ops/s

Write TPS (10 min)

The write TPS within a 600-second window.

rocketmq_brokeruntime_put_tps60

gauge

ops/s

Write TPS (1 min)

The write TPS within a 60-second window.

rocketmq_brokeruntime_put_tps10

gauge

ops/s

Write TPS (10 sec)

The write TPS within a 10-second window.

rocketmq_brokeruntime_put_latency_99

gauge

ms

Write latency P99

The 99th percentile of message write latency, in milliseconds.

rocketmq_brokeruntime_put_latency_999

gauge

ms

Write latency P999

The 999th percentile of message write latency, in milliseconds.

rocketmq_brokeruntime_dispatch_maxbuffer

gauge

bytes

Max dispatch buffer

The maximum dispatch buffer size in bytes.

rocketmq_brokeruntime_pull_threadpoolqueue_capacity

gauge

-

Pull thread pool queue capacity

The queue capacity of the broker's pull thread pool.

rocketmq_brokeruntime_send_threadpoolqueue_capacity

gauge

-

Send thread pool queue capacity

The queue capacity of the broker's send thread pool.

rocketmq_brokeruntime_pull_threadpoolqueue_size

gauge

-

Pull thread pool queue size

The current size of the broker's pull thread pool queue.

rocketmq_brokeruntime_query_threadpoolqueue_size

gauge

-

Query thread pool queue size

The current size of the broker's query thread pool queue.

rocketmq_brokeruntime_pull_threadpoolqueue_headwait_timemills

gauge

ms

Pull queue head wait time

The wait time for the head of the pull thread pool queue, in milliseconds.

rocketmq_brokeruntime_query_threadpoolqueue_headwait_timemills

gauge

ms

Query queue head wait time

The wait time for the head of the query thread pool queue, in milliseconds.

rocketmq_brokeruntime_send_threadpoolqueue_headwait_timemills

gauge

ms

Send queue head wait time

The wait time for the head of the send thread pool queue, in milliseconds.

rocketmq_brokeruntime_msg_gettotal_yesterdaymorning

gauge

-

Total reads as of yesterday morning

The cumulative total number of messages read as of yesterday morning.

rocketmq_brokeruntime_msg_puttotal_yesterdaymorning

gauge

-

Total writes as of yesterday morning

The cumulative total number of messages written as of yesterday morning.

rocketmq_brokeruntime_msg_gettotal_todaymorning

gauge

-

Total reads as of this morning

The cumulative total number of messages read as of this morning.

rocketmq_brokeruntime_msg_puttotal_todaymorning

gauge

-

Total writes as of this morning

The cumulative total number of messages written as of this morning.

rocketmq_brokeruntime_commitlogdir_capacity_free

gauge

bytes

Free capacity of CommitLog directory

The remaining free capacity of the CommitLog directory in bytes.

rocketmq_brokeruntime_commitlogdir_capacity_total

gauge

bytes

Total capacity of CommitLog directory

The total capacity of the CommitLog directory in bytes.

rocketmq_brokeruntime_commitlog_maxoffset

gauge

-

CommitLog latest offset

The latest offset of the CommitLog on the broker.

rocketmq_brokeruntime_commitlog_minoffset

gauge

-

CommitLog earliest offset

The earliest offset of the CommitLog on the broker.

rocketmq_brokeruntime_remain_howmanydata_toflush

gauge

bytes

Data volume to be flushed

The volume of data that still needs to be flushed to disk, in bytes.

In addition to the preceding MetricSet aggregated metrics, the raw metrics (rocketmq_*) collected by the exporter are also written to Prometheus storage and can be queried directly using Prometheus Query Language (PromQL).

Common query examples

# Consumer group accumulation
rocketmq_group_diff

# Broker production TPS
rocketmq_broker_tps

# CommitLog disk usage
rocketmq_brokeruntime_commitlog_disk_ratio

Alert templates

This integration component does not have built-in alert rules. You can configure alerts in Alert Center based on the preceding metrics. For example, you can set alerts for scenarios such as when the rocketmq_broker_tps liveness metric is not equal to 1, or when the number of connections or the message accumulation exceeds a threshold.

Storage policies

After you integrate RocketMQ, Cloud Monitor creates a corresponding storage instance to store observable data.

Data type

Default storage location

Notes

Metrics

Prometheus instance: RegionShare:{{workspaceName}}:{{regionId}}

Associated dataset: middleware.metric.rocketmq

Manage or remove the integration

To modify or cancel the integration, go to the Integration Management page of Integration Center, find the corresponding integration policy, and then click Edit or Delete. When you delete the integration policy, the Exporter and the collection configuration are removed together. Historical metrics that have already been written are retained based on the lifecycle policy of the storage.