Pulsar exposes metrics in Prometheus format that can be collected and used for monitoring the health of the cluster.

概述

The metrics exposed by Pulsar are in Prometheus format. The types of metrics are:

  • Counter: a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.
  • Gauge: a gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
  • Histogram: 直方图样本观测 (通常是请求持续时间和响应大小) ,并将它们计入可配置的 bucket 中。
  • Summary: 与直方图类似的总结样本观察 (通常是请求持续时间和响应大小)。 但它同时也提供了总观测次数以及所有观测值的总和,它会在滑动的时间窗口上计算可配置的分位数。

ZooKeeper

The ZooKeeper metrics are exposed under “/metrics” at port 8000. You can use a different port by configuring the stats_server_port system property.

服务器度量值

Name类型Description
zookeeper_server_znode_count计量表存储的 z-nodes 数量。
zookeeper_server_data_size_bytes计量表储存的所有 z-nodes 的总大小。
zookeeper_server_connections计量表当前打开的连接数量。
zookeeper_server_watches_count计量表注册的观察者数量。
zookeeper_server_ephemerals_count计量表临时 z-nodes 的数量。

请求度量值

Name类型Description
zookeeper_server_requests计数器特定服务器收到请求的总数。
zookeeper_server_requests_latency_ms总结按毫秒计算的请求延迟。
Available labels: type (write, read).
  • write: 将数据写入 ZooKeeper 的请求。
  • read: 从 ZooKeeper 读数据的请求。

BookKeeper

The BookKeeper metrics are exposed under “/metrics” at port 8000. You can change the port by updating prometheusStatsHttpPort in bookkeeper.conf configuration file.

服务器度量值

Name类型Description
bookie_SERVER_STATUS计量表bookie 服务器的服务状态。
  • 1: bookie 正运行于可写入模式。
  • 0: bookie 正运行于只读模式。
bookkeeper_server_ADD_ENTRY_count计数器The total number of ADD_ENTRY requests received at the bookie. success 标签会被用于区分成功与失败。
bookkeeper_server_READ_ENTRY_count计数器The total number of READ_ENTRY requests received at the bookie. success 标签会被用于区分成功与失败。
bookie_WRITE_BYTES计数器The total number of bytes written to the bookie.
bookie_READ_BYTES计数器The total number of bytes read from the bookie.
bookkeeper_server_ADD_ENTRY_REQUEST直方图The histogram of request latency of ADD_ENTRY requests at the bookie. success 标签会被用于区分成功与失败。
bookkeeper_server_READ_ENTRY_REQUEST直方图The histogram of request latency of READ_ENTRY requests at the bookie. success 标签会被用于区分成功与失败。

日志度量值

Name类型Description
bookie_journal_JOURNAL_SYNC_count计数器bookie 中日志 fsync 操作的总次数。 success 标签会被用于区分成功与失败。
bookie_journal_JOURNAL_QUEUE_SIZE计量表日志队列中待处理的请求总数。
bookie_journal_JOURNAL_FORCE_WRITE_QUEUE_SIZE计量表在强制写入队列中等待的强制写入 (fsync) 请求总数。
bookie_journal_JOURNAL_CB_QUEUE_SIZE计量表回调队列中待处理的回调总数。
bookie_journal_JOURNAL_ADD_ENTRY直方图在日志中添加条目的请求延迟的直方图。
bookie_journal_JOURNAL_SYNC直方图同步数据到日志磁盘的 fsync 延迟的直方图。

存储度量值

Name类型Description
bookie_ledgers_count计量表bookie 中存储的 ledger 总数。
bookie_entries_count计量表bookie 中存储的条目总数。
bookie_write_cache_size计量表bookie 的写缓存大小(以字节为单位)。
bookie_read_cache_size计量表bookie 的读缓存大小(以字节为单位)。
bookie_DELETED_LEDGER_COUNT计数器bookie 被启动以来被删除的 ledger 总数。
bookie_ledger_writable_dirs计量表bookie 中可写入目录的数量。

Broker

The broker metrics are exposed under “/metrics” at port 8080. You can change the port by updating webServicePort to a different port in broker.conf configuration file.

broker 暴露的所有度量值会带有 cluster=${pulsar_cluster} 标签。 The value of ${pulsar_cluster} is the pulsar cluster name you configured in broker.conf.

Broker has the following kinds of metrics:

命名空间度量值

命名空间度量值只有在 exposeTopicLevelMetricsInPrometheus 被设为 false 时才暴露。

所有命名空间度量值都带有以下标签:

  • cluster: cluster=${pulsar_cluster}. ${pulsar_cluster} 就是你在 broker.conf 中配置的集群名称。
  • namespace: namespace=${pulsar_namespace}. ${pulsar_namespace} 是命名空间名称。
Name类型Description
pulsartopics_count计量表命名空间下由此 broker 拥有的 Pulsar 主题数。
pulsar_subscriptions_count计量表命名空间下由此 broker 服务的 Pulsar 订阅数。
pulsar_producers_count计量表命名空间下连接到此 broker 的活动生产者数。
pulsar_consumers_count计量表命名空间下连接到此 broker 的活动消费者数。
pulsar_rate_in计量表命名空间下的所有消息进入此 broker 的频率(消息/秒)。
pulsar_rate_out计量表命名空间下的所有消息从此 broker 发出的频率(消息/秒)。
pulsar_throughput_in计量表命名空间下数据进入此 broker 的总吞吐量(字节/秒)。
pulsar_throughput_out计量表命名空间下数据由此 broker 发出的总吞吐量(字节/秒)。
pulsar_storage_size计量表命名空间下由此 broker 拥有的主题的总存储大小 (字节)。
pulsar_storage_backlog_size计量表命名空间下由此 broker 拥有的总积压大小 (消息)。
pulsar_storage_offloaded_size计量表此命名空间中已卸载到层级存储的数据总量(字节)。
pulsar_storage_write_rate计量表此命名空间写入到存储的总消息批处理(条目)数 (消息批处理/秒)。
pulsar_storage_read_rate计量表此命名空间从存储中读取的总消息批处理(条目)数 (消息批处理/秒)。
pulsar_subscription_delayed计量表被延迟派发的总消息批处理(条目)数。
pulsar_storage_write_latency_le直方图The entry rate of a namespace that the storage write latency is smaller with a given threshold.
可用的阈值:
  • pulsarstorage_write_latency_le_0_5: <= 0.5ms
  • pulsar_storage_write_latency_le_1: <= 1ms
  • pulsar_storage_write_latency_le_5: <= 5ms
  • pulsar_storage_write_latency_le_10: <= 10ms
  • pulsar_storage_write_latency_le_20: <= 20ms
  • pulsar_storage_write_latency_le_50: <= 50ms
  • pulsar_storage_write_latency_le_100: <= 100ms
  • pulsar_storage_write_latency_le_200: <= 200ms
  • pulsar_storage_write_latency_le_1000: <= 1s
  • pulsar_storage_write_latency_le_overflow: > 1s
pulsar_entry_size_le直方图The entry rate of a namespace that the entry size is smaller with a given threshold.
Available thresholds:
  • pulsar_entry_size_le_128: <= 128 bytes
  • pulsar_entry_size_le_512: <= 512 bytes
  • pulsar_entry_size_le_1_kb: <= 1 KB
  • pulsar_entry_size_le_2_kb: <= 2 KB
  • pulsar_entry_size_le_4_kb: <= 4 KB
  • pulsar_entry_size_le_16_kb: <= 16 KB
  • pulsar_entry_size_le_100_kb: <= 100 KB
  • pulsar_entry_size_le_1_mb: <= 1 MB
  • pulsar_entry_size_le_overflow: > 1 MB

复制度量值

If a namespace is configured to be replicated between multiple Pulsar clusters, the corresponding replication metrics will also be exposed when replicationMetricsEnabled is enabled.

All the replication metrics will also be labelled with remoteCluster=${pulsar_remote_cluster}.

Name类型Description
pulsar_replication_rate_in计量表命名空间从远程集群进行复制的总消息频率(消息/秒)。
pulsar_replication_rate_out计量表命名空间复制到远程集群的总消息频率(消息/秒)。
pulsar_replication_throughput_in计量表命名空间从远程集群进行复制的总吞吐量(字节/秒)。
pulsar_replication_throughput_out计量表命名空间复制到远程集群的总吞吐量(字节/秒)。
pulsar_replication_backlog计量表命名空间复制到远程集群的总积压量(消息)。

主题度量值

Topic metrics are only exposed when exposeTopicLevelMetricsInPrometheus is set to true.

所有主题度量值都带有以下标签:

  • cluster: cluster=${pulsar_cluster}. ${pulsar_cluster} 就是你在 broker.conf 中配置的集群名称。
  • namespace: namespace=${pulsar_namespace}. ${pulsar_namespace} 是命名空间名称。
  • topic: topic=${pulsar_topic}. ${pulsar_topic} 是主题名。
Name类型Description
pulsarsubscriptions_count计量表主题下由此 broker 服务的 Pulsar 订阅数。
pulsar_producers_count计量表主题下连接到此 broker 的活动生产者数。
pulsar_consumers_count计量表主题下连接到此 broker 的活动消费者数。
pulsar_rate_in计量表主题下的所有消息进入此 broker 的频率(消息/秒)。
pulsar_rate_out计量表主题下的所有消息从此 broker 发出的频率(消息/秒)。
pulsar_throughput_in计量表主题下数据进入此 broker 的总吞吐量(字节/秒)。
pulsar_throughput_out计量表主题下数据由此 broker 发出的总吞吐量(字节/秒)。
pulsar_storage_size计量表主题下由此 broker 拥有的主题的总存储大小 (字节)。
pulsar_storage_backlog_size计量表主题下由此 broker 拥有的总积压大小 (消息)。
pulsar_storage_offloaded_size计量表此主题中已卸载到层级存储的数据总量(字节)。
pulsar_storage_backlog_quota_limit计量表此主题中限制积压定额的数据总量(字节)。
pulsar_storage_write_rate计量表此主题写入到存储的总消息批处理(条目)数 (消息批处理/秒)。
pulsar_storage_read_rate计量表此主题从存储中读取的总消息批处理(条目)数 (消息批处理/秒)。
pulsar_subscription_delayed计量表被延迟派发的总消息批处理(条目)数。
pulsar_storage_write_latency_le直方图The entry rate of a topic that the storage write latency is smaller with a given threshold.
可用的阈值:
  • pulsarstorage_write_latency_le_0_5: <= 0.5ms
  • pulsar_storage_write_latency_le_1: <= 1ms
  • pulsar_storage_write_latency_le_5: <= 5ms
  • pulsar_storage_write_latency_le_10: <= 10ms
  • pulsar_storage_write_latency_le_20: <= 20ms
  • pulsar_storage_write_latency_le_50: <= 50ms
  • pulsar_storage_write_latency_le_100: <= 100ms
  • pulsar_storage_write_latency_le_200: <= 200ms
  • pulsar_storage_write_latency_le_1000: <= 1s
  • pulsar_storage_write_latency_le_overflow: > 1s
pulsar_entry_size_le直方图The entry rate of a topic that the entry size is smaller with a given threshold.
Available thresholds:
  • pulsar_entry_size_le_128: <= 128 bytes
  • pulsar_entry_size_le_512: <= 512 bytes
  • pulsar_entry_size_le_1_kb: <= 1 KB
  • pulsar_entry_size_le_2_kb: <= 2 KB
  • pulsar_entry_size_le_4_kb: <= 4 KB
  • pulsar_entry_size_le_16_kb: <= 16 KB
  • pulsar_entry_size_le_100_kb: <= 100 KB
  • pulsar_entry_size_le_1_mb: <= 1 MB
  • pulsar_entry_size_le_overflow: > 1 MB
pulsar_in_bytes_total计数器The total number of bytes received for this topic
pulsar_in_messages_total计数器The total number of messages received for this topic

复制度量值

If a namespace that a topic belongs to is configured to be replicated between multiple Pulsar clusters, the corresponding replication metrics will also be exposed when replicationMetricsEnabled is enabled.

All the replication metrics will also be labelled with remoteCluster=${pulsar_remote_cluster}.

Name类型Description
pulsar_replication_rate_in计量表主题从远程集群进行复制的总消息频率(消息/秒)。
pulsar_replication_rate_out计量表主题复制到远程集群的总消息频率(消息/秒)。
pulsar_replication_throughput_in计量表主题从远程集群进行复制的总吞吐量(字节/秒)。
pulsar_replication_throughput_out计量表主题复制到远程集群的总吞吐量(字节/秒)。
pulsar_replication_backlog计量表主题复制到远程集群的总积压量(消息)。

Subscription metrics

Subscription metrics are only exposed when exposeTopicLevelMetricsInPrometheus is set to true.

All the subscription metrics are labelled with the following labels:

  • cluster: cluster=${pulsar_cluster}. ${pulsar_cluster} 就是你在 broker.conf 中配置的集群名称。
  • namespace: namespace=${pulsar_namespace}. ${pulsar_namespace} 是命名空间名称。
  • topic: topic=${pulsar_topic}. ${pulsar_topic} 是主题名。
  • subscription: subscription=${subscription}. ${subscription} is the topic subscription name.
Name类型Description
pulsar_subscription_back_log计量表The total backlog of a subscription (messages).
pulsar_subscription_delayed计量表The total number of messages are delayed to be dispatched for a subscription (messages).
pulsar_subscription_msg_rate_redeliver计量表The total message rate for message being redelivered (messages/second).
pulsar_subscription_unacked_messages计量表The total number of unacknowledged messages of a subscription (messages).
pulsar_subscription_blocked_on_unacked_messages计量表Indicate whether a subscription is blocked on unacknowledged messages or not.
  • 1 means the subscription is blocked on waiting unacknowledged messages to be acked.
  • 0 means the subscription is not blocked on waiting unacknowledged messages to be acked.
pulsar_subscription_msg_rate_out计量表The total message dispatch rate for a subscription (messages/second).
pulsar_subscription_msg_throughput_out计量表The total message dispatch throughput for a subscription (bytes/second).

Consumer metrics

Consumer metrics are only exposed when both exposeTopicLevelMetricsInPrometheus and exposeConsumerLevelMetricsInPrometheus are set to true.

All the consumer metrics are labelled with the following labels:

  • cluster: cluster=${pulsar_cluster}. ${pulsar_cluster} 就是你在 broker.conf 中配置的集群名称。
  • namespace: namespace=${pulsar_namespace}. ${pulsar_namespace} 是命名空间名称。
  • topic: topic=${pulsar_topic}. ${pulsar_topic} 是主题名。
  • subscription: subscription=${subscription}. ${subscription} is the topic subscription name.
  • consumer_name: consumer_name=${consumer_name}. ${consumer_name} is the topic consumer name.
  • consumer_id: consumer_id=${consumer_id}. ${consumer_id} is the topic consumer id.
Name类型Description
pulsar_consumer_msg_rate_redeliver计量表The total message rate for message being redelivered (messages/second).
pulsar_consumer_unacked_messages计量表The total number of unacknowledged messages of a consumer (messages).
pulsar_consumer_blocked_on_unacked_messages计量表Indicate whether a consumer is blocked on unacknowledged messages or not.
  • 1 means the consumer is blocked on waiting unacknowledged messages to be acked.
  • 0 means the consumer is not blocked on waiting unacknowledged messages to be acked.
pulsar_consumer_msg_rate_out计量表The total message dispatch rate for a consumer (messages/second).
pulsar_consumer_msg_throughput_out计量表The total message dispatch throughput for a consumer (bytes/second).
pulsar_consumer_available_permits计量表The available permits for for a consumer.

Monitor

You can set up a Prometheus instance to collect all the metrics exposed at Pulsar components and set up Grafana dashboards to display the metrics and monitor your Pulsar cluster.

The following are some Grafana dashboards examples:

  • pulsar-grafana: A grafana dashboard that displays metrics collected in Prometheus for Pulsar clusters running on Kubernetes.
  • apache-pulsar-grafana-dashboard: A collection of grafana dashboard templates for different Pulsar components running on both Kubernetes and on-premise machines.