rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vongosl...@apache.org
Subject [rocketmq-exporter] 11/33: amend some metric name and make the metric have fixed Precision“
Date Mon, 22 Jul 2019 09:51:09 GMT
This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-exporter.git

commit 2d22503d2cd3722ff11db1f8e61fbe73586a61be
Author: fengqing <fengqing@sunlands.com>
AuthorDate: Tue Jul 2 17:42:51 2019 +0800

    amend some metric name and make the metric have fixed Precision“
---
 README.md                                          | 62 +++++++++++-----------
 rocketmq_exporter_overview.json                    |  8 +--
 .../exporter/collector/RMQMetricsCollector.java    |  4 +-
 .../rocketmq/exporter/task/MetricsCollectTask.java | 17 +++---
 .../org/apache/rocketmq/exporter/util/Mix.java     | 24 +++++++++
 5 files changed, 70 insertions(+), 45 deletions(-)

diff --git a/README.md b/README.md
index d1eda8f..9e04be5 100644
--- a/README.md
+++ b/README.md
@@ -85,16 +85,16 @@ Documents about exposed Prometheus metrics.
 
 | Name         | Exposed information                                  |
 | ------------ | ---------------------------------------------------- |
-| `rocketmq_broker_tps` | total put message numbers per second for this broker |
-| `rocketmq_broker_qps` | total get message numbers per second for this broker |
+| `rocketmq_broker_tps` | Broker produces the number of messages per second |
+| `rocketmq_broker_qps` | Broker consumes messages per second |
 
 **Metrics output example**
 
 ```txt
 # HELP rocketmq_broker_tps BrokerPutNums
 # TYPE rocketmq_broker_tps gauge
-rocketmq_broker_tps{cluster="MQCluster",broker="broker-a",} 7.933333333333334
-rocketmq_broker_tps{cluster="MQCluster",broker="broker-b",} 7.916666666666667
+rocketmq_broker_tps{cluster="MQCluster",broker="broker-a",} 7.93
+rocketmq_broker_tps{cluster="MQCluster",broker="broker-b",} 7.91
 # HELP rocketmq_broker_qps BrokerGetNums
 # TYPE rocketmq_broker_qps gauge
 rocketmq_broker_qps{cluster="MQCluster",broker="broker-a",} 8.2
@@ -107,21 +107,21 @@ rocketmq_broker_qps{cluster="MQCluster",broker="broker-b",} 8.15
 
 | Name                | Exposed information                                |
 | ------------------- | -------------------------------------------------- |
-| `rocketmq_producer_tps`      | sending messages number per second  for this topic |
-| `rocketmq_producer_put_size` | sending messages size per second  for this topic   |
-| `rocketmq_producer_offset`   | Current Offset of a Broker for this topic          |
+| `rocketmq_producer_tps`      | The number of messages produced per second per topic |
+| `rocketmq_producer_message_size` | The size of a message produced per second by a topic
(in bytes) |
+| `rocketmq_producer_offset`   | The progress of a topic's production message |
 
 **Metrics output example**
 
 ```txt
 # HELP rocketmq_producer_tps TopicPutNums
 # TYPE rocketmq_producer_tps gauge
-rocketmq_producer_tps{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",} 7.933333333333334
-rocketmq_producer_tps{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",} 7.916666666666667
-# HELP rocketmq_producer_put_size TopicPutSize
-# TYPE rocketmq_producer_put_size gauge
-rocketmq_producer_put_size{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",}
1642.2
-rocketmq_producer_put_size{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",}
1638.75
+rocketmq_producer_tps{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",} 7.93
+rocketmq_producer_tps{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",} 7.91
+# HELP rocketmq_producer_message_size TopicPutMessageSize
+# TYPE rocketmq_producer_message_size gauge
+rocketmq_producer_message_size{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",}
1642.2
+rocketmq_producer_message_size{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",}
1638.75
 # HELP rocketmq_producer_offset TopicOffset
 # TYPE rocketmq_producer_offset counter
 rocketmq_producer_offset{cluster="MQCluster",broker="broker-a",topic="TBW102",} 0.0
@@ -153,25 +153,25 @@ rocketmq_producer_offset{cluster="MQCluster",broker="broker-a",topic="DEV_TID_20
 
 **Metrics details**
 
-| Name                              | Exposed information                               
          |
-| --------------------------------- | ------------------------------------------------------------
|
-| `rocketmq_consumer_tps`                    | consumer message numbers per second for this
Topic           |
-| `rocketmq_consumer_get_size`               | consumer message size per second for this
Topic              |
-| `rocketmq_consumer_offset`                 | consumer offset for this topic           
                   |
-| `rocketmq_group_get_latency`               | consumer latency on some topic for one queue
                |
-| `rocketmq_group_get_latency_by_storetime ` | consumer latency between message consume time
and message store time on some topic |
+| Name                                       | Exposed information                      
                   |
+| ------------------------------------------ | ------------------------------------------------------------
|
+| `rocketmq_consumer_tps`                    | The number of messages consumed per second
by a consumer group |
+| `rocketmq_consumer_message_size`           | The size of the message consumed by the consumer
group per second (in bytes) |
+| `rocketmq_consumer_offset`                 | Progress of consumption message for a consumer
group         |
+| `rocketmq_group_get_latency`               | Consumer latency on some topic for one queue
                |
+| `rocketmq_group_get_latency_by_storetime ` | Consumption delay time of a consumer group
                  |
 
 **Metrics output example**
 
 ```txt
 # HELP rocketmq_consumer_tps GroupGetNums
 # TYPE rocketmq_consumer_tps gauge
-rocketmq_consumer_tps{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
7.916666666666667
-rocketmq_consumer_tps{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
7.933333333333334
-# HELP rocketmq_consumer_get_size GroupGetSize
-# TYPE rocketmq_consumer_get_size gauge
-rocketmq_consumer_get_size{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
1638.75
-rocketmq_consumer_get_size{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
1642.2
+rocketmq_consumer_tps{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
7.91
+rocketmq_consumer_tps{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
7.93
+# HELP rocketmq_consumer_message_size GroupGetMessageSize
+# TYPE rocketmq_consumer_message_size gauge
+rocketmq_consumer_message_size{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
1638.75
+rocketmq_consumer_message_size{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
1642.2
 # HELP rocketmq_consumer_offset GroupOffset
 # TYPE rocketmq_consumer_offset counter
 rocketmq_consumer_offset{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",}
1462030.0
@@ -183,17 +183,17 @@ rocketmq_consumer_offset{cluster="MQCluster",broker="broker-b",topic="DEV_TID_tf
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="0",}
0.05
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="1",}
0.0
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="7",}
0.05
-rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="6",}
0.016666666666666666
+rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="6",}
0.01
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="3",}
0.0
-rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="7",}
0.03333333333333333
+rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="7",}
0.03
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="4",}
0.0
-rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="5",}
0.03333333333333333
-rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="6",}
0.016666666666666666
+rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="5",}
0.03
+rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="6",}
0.01
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="2",}
0.0
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="3",}
0.0
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="0",}
0.0
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="4",}
0.0
-rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="1",}
0.03333333333333333
+rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="1",}
0.03
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-b",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="5",}
0.0
 rocketmq_group_get_latency{cluster="MQCluster",broker="broker-a",topic="DEV_TID_topic_tfq",group="DEV_CID_consumer_cfq",queueid="2",}
0.0
 # HELP rocketmq_group_get_latency_by_storetime GroupGetLatencyByStoreTime
diff --git a/rocketmq_exporter_overview.json b/rocketmq_exporter_overview.json
index 537b21d..0bd1691 100644
--- a/rocketmq_exporter_overview.json
+++ b/rocketmq_exporter_overview.json
@@ -259,7 +259,7 @@
       "steppedLine": false,
       "targets": [
         {
-          "expr": "rocketmq_consumer_get_size",
+          "expr": "rocketmq_consumer_message_size",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A"
@@ -269,7 +269,7 @@
       "timeFrom": null,
       "timeRegions": [],
       "timeShift": null,
-      "title": "rocketmq_consumer_get_size",
+      "title": "rocketmq_consumer_message_size",
       "tooltip": {
         "shared": true,
         "sort": 0,
@@ -514,7 +514,7 @@
       "steppedLine": false,
       "targets": [
         {
-          "expr": "rocketmq_producer_put_size",
+          "expr": "rocketmq_producer_message_size",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A"
@@ -524,7 +524,7 @@
       "timeFrom": null,
       "timeRegions": [],
       "timeShift": null,
-      "title": "rocketmq_producer_put_size",
+      "title": "rocketmq_producer_message_size",
       "tooltip": {
         "shared": true,
         "sort": 0,
diff --git a/src/main/java/org/apache/rocketmq/exporter/collector/RMQMetricsCollector.java
b/src/main/java/org/apache/rocketmq/exporter/collector/RMQMetricsCollector.java
index dbaf4dd..2854712 100644
--- a/src/main/java/org/apache/rocketmq/exporter/collector/RMQMetricsCollector.java
+++ b/src/main/java/org/apache/rocketmq/exporter/collector/RMQMetricsCollector.java
@@ -62,7 +62,7 @@ public class RMQMetricsCollector extends Collector {
         mfs.add(topicPutNumsGauge);
 
 
-        GaugeMetricFamily topicPutSizeGauge = new GaugeMetricFamily("rocketmq_producer_put_size",
"TopicPutSize", Arrays.asList("cluster","broker","topic"));
+        GaugeMetricFamily topicPutSizeGauge = new GaugeMetricFamily("rocketmq_producer_message_size",
"TopicPutMessageSize", Arrays.asList("cluster","broker","topic"));
         for (Map.Entry<ProducerMetric, Double> entry: topicPutSize.entrySet()) {
             topicPutSizeGauge.addMetric(Arrays.asList(entry.getKey().getClusterName(),entry.getKey().getBrokerName(),entry.getKey().getTopicName()),
entry.getValue());
         }
@@ -98,7 +98,7 @@ public class RMQMetricsCollector extends Collector {
         mfs.add(groupGetNumsGauge);
 
 
-        GaugeMetricFamily groupGetSizeGauge = new GaugeMetricFamily("rocketmq_consumer_get_size",
"GroupGetSize", Arrays.asList("cluster","broker","topic","group"));
+        GaugeMetricFamily groupGetSizeGauge = new GaugeMetricFamily("rocketmq_consumer_message_size",
"GroupGetMessageSize", Arrays.asList("cluster","broker","topic","group"));
         for (Map.Entry<ConsumerMetric, Double> entry: groupGetSize.entrySet()) {
             groupGetSizeGauge.addMetric(Arrays.asList(entry.getKey().getClusterName(),entry.getKey().getBrokerName(),entry.getKey().getTopicName(),entry.getKey().getConsumerGroupName()),
entry.getValue());
         }
diff --git a/src/main/java/org/apache/rocketmq/exporter/task/MetricsCollectTask.java b/src/main/java/org/apache/rocketmq/exporter/task/MetricsCollectTask.java
index 6ae442d..7797d2a 100644
--- a/src/main/java/org/apache/rocketmq/exporter/task/MetricsCollectTask.java
+++ b/src/main/java/org/apache/rocketmq/exporter/task/MetricsCollectTask.java
@@ -35,6 +35,7 @@ import org.apache.rocketmq.exporter.aspect.admin.annotation.MultiMQAdminCmdMetho
 import org.apache.rocketmq.exporter.config.RMQConfigure;
 import org.apache.rocketmq.exporter.service.RMQMetricsService;
 import org.apache.rocketmq.exporter.service.client.MQAdminExtImpl;
+import org.apache.rocketmq.exporter.util.Mix;
 import org.apache.rocketmq.store.stats.BrokerStatsManager;
 import org.apache.rocketmq.tools.admin.MQAdminExt;
 import org.slf4j.Logger;
@@ -158,14 +159,14 @@ public class MetricsCollectTask {
                             BrokerStatsData bsd = null;
                             try {
                                 bsd = mqAdminExt.viewBrokerStatsData(masterAddr, BrokerStatsManager.TOPIC_PUT_NUMS,
topic);
-                                metricsService.getCollector().AddTopicPutNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, bsd.getStatsMinute().getTps());
+                                metricsService.getCollector().AddTopicPutNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                             }
                             catch (Exception e) {
                                 log.info("error is " + e.getMessage());
                             }
                             try {
                                 bsd = mqAdminExt.viewBrokerStatsData(masterAddr, BrokerStatsManager.TOPIC_PUT_SIZE,
topic);
-                                metricsService.getCollector().AddTopicPutSizeMetric(bd.getCluster(),
bd.getBrokerName(), topic, bsd.getStatsMinute().getTps());
+                                metricsService.getCollector().AddTopicPutSizeMetric(bd.getCluster(),
bd.getBrokerName(), topic, Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                             }
                             catch (Exception e) {
                                 log.info("error is " + e.getMessage());
@@ -185,20 +186,20 @@ public class MetricsCollectTask {
                                     BrokerStatsData bsd = null;
                                     try {
                                         bsd = mqAdminExt.viewBrokerStatsData(masterAddr,
BrokerStatsManager.GROUP_GET_NUMS, statsKey);
-                                        metricsService.getCollector().AddGroupGetNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, bsd.getStatsMinute().getTps());
+                                        metricsService.getCollector().AddGroupGetNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                                     } catch (Exception e) {
                                         log.info("error is " + e.getMessage());
                                     }
                                     try {
                                         bsd = mqAdminExt.viewBrokerStatsData(masterAddr,
BrokerStatsManager.GROUP_GET_SIZE, statsKey);
-                                        metricsService.getCollector().AddGroupGetSizeMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, bsd.getStatsMinute().getTps());
+                                        metricsService.getCollector().AddGroupGetSizeMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                                     } catch (Exception e) {
                                         log.info("error is " + e.getMessage());
                                     }
                                     try {
 
                                         bsd = mqAdminExt.viewBrokerStatsData(masterAddr,
BrokerStatsManager.SNDBCK_PUT_NUMS, statsKey);
-                                        metricsService.getCollector().AddsendBackNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, bsd.getStatsMinute().getTps());
+                                        metricsService.getCollector().AddsendBackNumsMetric(bd.getCluster(),
bd.getBrokerName(), topic, group, Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                                     } catch (Exception e) {
                                         log.info("error is " + e.getMessage());
                                     }
@@ -238,14 +239,14 @@ public class MetricsCollectTask {
                         BrokerStatsData bsd = null;
                         try {
                             bsd = mqAdminExt.viewBrokerStatsData(masterAddr, BrokerStatsManager.BROKER_PUT_NUMS,clusterEntry.getValue().getCluster());
-                            metricsService.getCollector().AddBrokerPutNumsMetric(clusterEntry.getValue().getCluster(),
clusterEntry.getValue().getBrokerName(), bsd.getStatsMinute().getTps());
+                            metricsService.getCollector().AddBrokerPutNumsMetric(clusterEntry.getValue().getCluster(),
clusterEntry.getValue().getBrokerName(), Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                         }
                         catch (Exception e) {
                             log.info("error is " + e.getMessage());
                         }
                         try {
                             bsd = mqAdminExt.viewBrokerStatsData(masterAddr, BrokerStatsManager.BROKER_GET_NUMS,
clusterEntry.getValue().getCluster());
-                            metricsService.getCollector().AddBrokerGetNumsMetric(clusterEntry.getValue().getCluster(),
clusterEntry.getValue().getBrokerName(), bsd.getStatsMinute().getTps());
+                            metricsService.getCollector().AddBrokerGetNumsMetric(clusterEntry.getValue().getCluster(),
clusterEntry.getValue().getBrokerName(), Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
                         }
                         catch (Exception e) {
                             log.info("error is " + e.getMessage());
@@ -273,7 +274,7 @@ public class MetricsCollectTask {
             statsKey = String.format("%d@%s@%s", queueId, topic, group);
             try {
                 bsd = mqAdminExt.viewBrokerStatsData(masterAddr, BrokerStatsManager.GROUP_GET_LATENCY,
statsKey);
-                metricsService.getCollector().AddGroupGetLatencyMetric(bd.getCluster(), bd.getBrokerName(),
topic, group, String.format("%d", queueId), bsd.getStatsMinute().getTps());
+                metricsService.getCollector().AddGroupGetLatencyMetric(bd.getCluster(), bd.getBrokerName(),
topic, group, String.format("%d", queueId), Mix.getFixedDouble(bsd.getStatsMinute().getTps()));
             } catch (Exception e) {
                 log.info("error is " + e.getMessage());
             }
diff --git a/src/main/java/org/apache/rocketmq/exporter/util/Mix.java b/src/main/java/org/apache/rocketmq/exporter/util/Mix.java
new file mode 100644
index 0000000..e51acff
--- /dev/null
+++ b/src/main/java/org/apache/rocketmq/exporter/util/Mix.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.rocketmq.exporter.util;
+
+public class Mix {
+    public static double getFixedDouble(double value) {
+        return Math.round(value * 100) / 100.0;
+    }
+}


Mime
View raw message