This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e6185ad0c [IOTDB-4038] Add the leader metrics to the cluster (#6923)
1e6185ad0c is described below

commit 1e6185ad0cace8b9b4fae17da3c06e596fb77543
Author: 23931017wu <[email protected]>
AuthorDate: Fri Aug 12 11:22:24 2022 +0800

    [IOTDB-4038] Add the leader metrics to the cluster (#6923)
---
 .../iotdb/confignode/manager/load/LoadManager.java | 207 +---------------
 .../manager/load/LoadManagerMetrics.java           | 272 +++++++++++++++++++++
 .../resources/confignode1conf/iotdb-metric.yml     |   2 +-
 .../resources/confignode2conf/iotdb-metric.yml     |   2 +-
 .../confignode3conf/iotdb-confignode.properties    |   2 +-
 .../resources/confignode3conf/iotdb-metric.yml     |   2 +-
 docs/UserGuide/Maintenance-Tools/Metric-Tool.md    |   4 +-
 docs/zh/UserGuide/Maintenance-Tools/Metric-Tool.md |   4 +-
 .../datanode1conf/iotdb-datanode.properties        |   2 +-
 .../test/resources/datanode1conf/iotdb-metric.yml  |   2 +-
 .../datanode2conf/iotdb-datanode.properties        |   3 +-
 .../test/resources/datanode2conf/iotdb-metric.yml  |   2 +-
 .../test/resources/datanode3conf/iotdb-metric.yml  |   2 +-
 13 files changed, 294 insertions(+), 212 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java
index 89a53e6df5..800ce1628d 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java
@@ -56,11 +56,6 @@ import 
org.apache.iotdb.confignode.manager.load.heartbeat.DataNodeHeartbeatCache
 import org.apache.iotdb.confignode.manager.load.heartbeat.INodeCache;
 import org.apache.iotdb.confignode.manager.load.heartbeat.IRegionGroupCache;
 import org.apache.iotdb.consensus.ConsensusFactory;
-import org.apache.iotdb.db.service.metrics.MetricsService;
-import org.apache.iotdb.db.service.metrics.enums.Metric;
-import org.apache.iotdb.db.service.metrics.enums.Tag;
-import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
-import org.apache.iotdb.metrics.utils.MetricLevel;
 import org.apache.iotdb.mpp.rpc.thrift.THeartbeatReq;
 import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq;
 
@@ -106,6 +101,7 @@ public class LoadManager {
 
   private final PartitionBalancer partitionBalancer;
   private final RouteBalancer routeBalancer;
+  private final LoadManagerMetrics loadManagerMetrics;
 
   /** Heartbeat executor service */
   private final AtomicInteger heartbeatCounter = new AtomicInteger(0);
@@ -131,6 +127,7 @@ public class LoadManager {
     this.regionBalancer = new RegionBalancer(configManager);
     this.partitionBalancer = new PartitionBalancer(configManager);
     this.routeBalancer = new RouteBalancer(configManager);
+    this.loadManagerMetrics = new LoadManagerMetrics(configManager);
   }
 
   /**
@@ -270,12 +267,13 @@ public class LoadManager {
                 TimeUnit.MILLISECONDS);
         LOGGER.info("LoadBalancing service is started successfully.");
       }
+      loadManagerMetrics.addMetrics();
     }
   }
 
   /** Stop the heartbeat service and the load balancing service */
   public void stop() {
-    removeMetrics();
+    loadManagerMetrics.removeMetrics();
     LOGGER.debug("Stop Heartbeat Service and LoadBalancing Service of 
LoadManager");
     synchronized (scheduleMonitor) {
       if (currentHeartbeatFuture != null) {
@@ -344,9 +342,6 @@ public class LoadManager {
     if (isNeedBroadcast) {
       broadcastLatestRegionRouteMap();
     }
-    if (nodeCacheMap.size() == getNodeManager().getRegisteredNodeCount()) {
-      addMetrics();
-    }
   }
 
   public void broadcastLatestRegionRouteMap() {
@@ -464,7 +459,7 @@ public class LoadManager {
             registeredConfigNode -> {
               int configNodeId = registeredConfigNode.getConfigNodeId();
               return nodeCacheMap.containsKey(configNodeId)
-                  && 
nodeCacheMap.get(configNodeId).getNodeStatus().equals(NodeStatus.Running);
+                  && 
NodeStatus.Running.equals(nodeCacheMap.get(configNodeId).getNodeStatus());
             })
         .collect(Collectors.toList());
   }
@@ -475,7 +470,7 @@ public class LoadManager {
             registeredDataNode -> {
               int id = registeredDataNode.getLocation().getDataNodeId();
               return nodeCacheMap.containsKey(id)
-                  && 
nodeCacheMap.get(id).getNodeStatus().equals(NodeStatus.Running);
+                  && 
NodeStatus.Running.equals(nodeCacheMap.get(id).getNodeStatus());
             })
         .collect(Collectors.toList());
   }
@@ -486,7 +481,7 @@ public class LoadManager {
             registeredConfigNode -> {
               int configNodeId = registeredConfigNode.getConfigNodeId();
               return nodeCacheMap.containsKey(configNodeId)
-                  && 
nodeCacheMap.get(configNodeId).getNodeStatus().equals(NodeStatus.Unknown);
+                  && 
NodeStatus.Unknown.equals(nodeCacheMap.get(configNodeId).getNodeStatus());
             })
         .collect(Collectors.toList());
   }
@@ -497,197 +492,11 @@ public class LoadManager {
             registeredDataNode -> {
               int id = registeredDataNode.getLocation().getDataNodeId();
               return nodeCacheMap.containsKey(id)
-                  && 
nodeCacheMap.get(id).getNodeStatus().equals(NodeStatus.Unknown);
+                  && 
NodeStatus.Unknown.equals(nodeCacheMap.get(id).getNodeStatus());
             })
         .collect(Collectors.toList());
   }
 
-  public int getRunningConfigNodesNum() {
-    List<TConfigNodeLocation> allConfigNodes = getOnlineConfigNodes();
-    if (allConfigNodes == null) {
-      return 0;
-    }
-    for (TConfigNodeLocation configNodeLocation : allConfigNodes) {
-      String name =
-          "EndPoint("
-              + configNodeLocation.getInternalEndPoint().ip
-              + ":"
-              + configNodeLocation.getInternalEndPoint().port
-              + ")";
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CLUSTER_NODE_STATUS.toString(),
-              MetricLevel.IMPORTANT,
-              Tag.NAME.toString(),
-              name,
-              Tag.TYPE.toString(),
-              "ConfigNode")
-          .set(1);
-    }
-    return allConfigNodes.size();
-  }
-
-  public int getRunningDataNodesNum() {
-    List<TDataNodeConfiguration> allDataNodes = getOnlineDataNodes();
-    if (allDataNodes == null) {
-      return 0;
-    }
-    for (TDataNodeConfiguration dataNodeInfo : allDataNodes) {
-      TDataNodeLocation dataNodeLocation = dataNodeInfo.getLocation();
-      String name =
-          "EndPoint("
-              + dataNodeLocation.getClientRpcEndPoint().ip
-              + ":"
-              + dataNodeLocation.getClientRpcEndPoint().port
-              + ")";
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CLUSTER_NODE_STATUS.toString(),
-              MetricLevel.IMPORTANT,
-              Tag.NAME.toString(),
-              name,
-              Tag.TYPE.toString(),
-              "DataNode")
-          .set(1);
-    }
-    return allDataNodes.size();
-  }
-
-  public int getUnknownConfigNodesNum() {
-    List<TConfigNodeLocation> allConfigNodes = getUnknownConfigNodes();
-    if (allConfigNodes == null) {
-      return 0;
-    }
-    for (TConfigNodeLocation configNodeLocation : allConfigNodes) {
-      String name =
-          "EndPoint("
-              + configNodeLocation.getInternalEndPoint().ip
-              + ":"
-              + configNodeLocation.getInternalEndPoint().port
-              + ")";
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CLUSTER_NODE_STATUS.toString(),
-              MetricLevel.IMPORTANT,
-              Tag.NAME.toString(),
-              name,
-              Tag.TYPE.toString(),
-              "ConfigNode")
-          .set(0);
-    }
-    return allConfigNodes.size();
-  }
-
-  public int getUnknownDataNodesNum() {
-    List<TDataNodeConfiguration> allDataNodes = getUnknownDataNodes();
-    if (allDataNodes == null) {
-      return 0;
-    }
-    for (TDataNodeConfiguration dataNodeInfo : allDataNodes) {
-      TDataNodeLocation dataNodeLocation = dataNodeInfo.getLocation();
-      String name =
-          "EndPoint("
-              + dataNodeLocation.getClientRpcEndPoint().ip
-              + ":"
-              + dataNodeLocation.getClientRpcEndPoint().port
-              + ")";
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CLUSTER_NODE_STATUS.toString(),
-              MetricLevel.IMPORTANT,
-              Tag.NAME.toString(),
-              name,
-              Tag.TYPE.toString(),
-              "DataNode")
-          .set(0);
-    }
-    return allDataNodes.size();
-  }
-
-  public void addMetrics() {
-    if 
(MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CONFIG_NODE.toString(),
-              MetricLevel.CORE,
-              Tag.NAME.toString(),
-              "total",
-              Tag.STATUS.toString(),
-              NodeStatus.Online.toString())
-          .set(getRunningConfigNodesNum());
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.DATA_NODE.toString(),
-              MetricLevel.CORE,
-              Tag.NAME.toString(),
-              "total",
-              Tag.STATUS.toString(),
-              NodeStatus.Online.toString())
-          .set(getRunningDataNodesNum());
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.CONFIG_NODE.toString(),
-              MetricLevel.CORE,
-              Tag.NAME.toString(),
-              "total",
-              Tag.STATUS.toString(),
-              NodeStatus.Unknown.toString())
-          .set(getUnknownConfigNodesNum());
-      MetricsService.getInstance()
-          .getMetricManager()
-          .getOrCreateGauge(
-              Metric.DATA_NODE.toString(),
-              MetricLevel.CORE,
-              Tag.NAME.toString(),
-              "total",
-              Tag.STATUS.toString(),
-              NodeStatus.Unknown.toString())
-          .set(getUnknownDataNodesNum());
-    }
-  }
-
-  public void removeMetrics() {
-    MetricsService.getInstance()
-        .getMetricManager()
-        .removeGauge(
-            Metric.CONFIG_NODE.toString(),
-            Tag.NAME.toString(),
-            "total",
-            Tag.STATUS.toString(),
-            NodeStatus.Online.toString());
-    MetricsService.getInstance()
-        .getMetricManager()
-        .removeGauge(
-            Metric.DATA_NODE.toString(),
-            Tag.NAME.toString(),
-            "total",
-            Tag.STATUS.toString(),
-            NodeStatus.Online.toString());
-    MetricsService.getInstance()
-        .getMetricManager()
-        .removeGauge(
-            Metric.CONFIG_NODE.toString(),
-            Tag.NAME.toString(),
-            "total",
-            Tag.STATUS.toString(),
-            NodeStatus.Unknown.toString());
-    MetricsService.getInstance()
-        .getMetricManager()
-        .removeGauge(
-            Metric.DATA_NODE.toString(),
-            Tag.NAME.toString(),
-            "total",
-            Tag.STATUS.toString(),
-            NodeStatus.Unknown.toString());
-  }
-
   public static void printRegionRouteMap(
       long timestamp, Map<TConsensusGroupId, TRegionReplicaSet> 
regionRouteMap) {
     LOGGER.info("[latestRegionRouteMap] timestamp:{}", timestamp);
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManagerMetrics.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManagerMetrics.java
new file mode 100644
index 0000000000..97df64204a
--- /dev/null
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManagerMetrics.java
@@ -0,0 +1,272 @@
+/*
+ * 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.iotdb.confignode.manager.load;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.cluster.NodeStatus;
+import org.apache.iotdb.commons.utils.NodeUrlUtils;
+import org.apache.iotdb.confignode.manager.IManager;
+import org.apache.iotdb.confignode.manager.NodeManager;
+import org.apache.iotdb.db.service.metrics.MetricsService;
+import org.apache.iotdb.db.service.metrics.enums.Metric;
+import org.apache.iotdb.db.service.metrics.enums.Tag;
+import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
+import org.apache.iotdb.metrics.utils.MetricLevel;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/** This class collates metrics about loadManager */
+public class LoadManagerMetrics {
+
+  private final IManager configManager;
+
+  public LoadManagerMetrics(IManager configManager) {
+    this.configManager = configManager;
+  }
+
+  public void addMetrics() {
+    addNodeMetrics();
+    addLeaderCount();
+  }
+
+  private int getRunningConfigNodesNum() {
+    List<TConfigNodeLocation> allConfigNodes =
+        configManager.getLoadManager().getOnlineConfigNodes();
+    if (allConfigNodes == null) {
+      return 0;
+    }
+    for (TConfigNodeLocation configNodeLocation : allConfigNodes) {
+      String name = 
NodeUrlUtils.convertTEndPointUrl(configNodeLocation.getInternalEndPoint());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.CLUSTER_NODE_STATUS.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              "ConfigNode")
+          .set(1);
+    }
+    return allConfigNodes.size();
+  }
+
+  private int getRunningDataNodesNum() {
+    List<TDataNodeConfiguration> allDataNodes = 
configManager.getLoadManager().getOnlineDataNodes();
+    if (allDataNodes == null) {
+      return 0;
+    }
+    for (TDataNodeConfiguration dataNodeInfo : allDataNodes) {
+      TDataNodeLocation dataNodeLocation = dataNodeInfo.getLocation();
+      String name = 
NodeUrlUtils.convertTEndPointUrl(dataNodeLocation.getClientRpcEndPoint());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.CLUSTER_NODE_STATUS.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              "DataNode")
+          .set(1);
+    }
+    return allDataNodes.size();
+  }
+
+  private int getUnknownConfigNodesNum() {
+    List<TConfigNodeLocation> allConfigNodes =
+        configManager.getLoadManager().getUnknownConfigNodes();
+    if (allConfigNodes == null) {
+      return 0;
+    }
+    for (TConfigNodeLocation configNodeLocation : allConfigNodes) {
+      String name = 
NodeUrlUtils.convertTEndPointUrl(configNodeLocation.getInternalEndPoint());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.CLUSTER_NODE_STATUS.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              "ConfigNode")
+          .set(0);
+    }
+    return allConfigNodes.size();
+  }
+
+  private int getUnknownDataNodesNum() {
+    List<TDataNodeConfiguration> allDataNodes =
+        configManager.getLoadManager().getUnknownDataNodes();
+    if (allDataNodes == null) {
+      return 0;
+    }
+    for (TDataNodeConfiguration dataNodeInfo : allDataNodes) {
+      TDataNodeLocation dataNodeLocation = dataNodeInfo.getLocation();
+      String name = 
NodeUrlUtils.convertTEndPointUrl(dataNodeLocation.getClientRpcEndPoint());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.CLUSTER_NODE_STATUS.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              "DataNode")
+          .set(0);
+    }
+    return allDataNodes.size();
+  }
+
+  public void addNodeMetrics() {
+    if 
(MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.CONFIG_NODE.toString(),
+              MetricLevel.CORE,
+              this,
+              o -> getRunningConfigNodesNum(),
+              Tag.NAME.toString(),
+              "total",
+              Tag.STATUS.toString(),
+              NodeStatus.Online.toString());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.DATA_NODE.toString(),
+              MetricLevel.CORE,
+              this,
+              o -> getRunningDataNodesNum(),
+              Tag.NAME.toString(),
+              "total",
+              Tag.STATUS.toString(),
+              NodeStatus.Online.toString());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.CONFIG_NODE.toString(),
+              MetricLevel.CORE,
+              this,
+              o -> getUnknownConfigNodesNum(),
+              Tag.NAME.toString(),
+              "total",
+              Tag.STATUS.toString(),
+              NodeStatus.Unknown.toString());
+
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.DATA_NODE.toString(),
+              MetricLevel.CORE,
+              this,
+              o -> getUnknownDataNodesNum(),
+              Tag.NAME.toString(),
+              "total",
+              Tag.STATUS.toString(),
+              NodeStatus.Unknown.toString());
+    }
+  }
+
+  /**
+   * Get the LeaderCount of Specific DataNodeId
+   *
+   * @return Integer
+   */
+  public Integer getLeadershipCountByDatanode(int dataNodeId) {
+    Map<Integer, Integer> idToCountMap = new ConcurrentHashMap<>();
+
+    configManager
+        .getLoadManager()
+        .getAllLeadership()
+        .forEach((consensusGroupId, nodeId) -> idToCountMap.merge(nodeId, 1, 
Integer::sum));
+    return idToCountMap.get(dataNodeId);
+  }
+
+  public void addLeaderCount() {
+    getNodeManager()
+        .getRegisteredDataNodes()
+        .forEach(
+            dataNodeInfo -> {
+              TDataNodeLocation dataNodeLocation = dataNodeInfo.getLocation();
+              int dataNodeId = dataNodeLocation.getDataNodeId();
+              String name =
+                  
NodeUrlUtils.convertTEndPointUrl(dataNodeLocation.getClientRpcEndPoint());
+
+              MetricsService.getInstance()
+                  .getMetricManager()
+                  .getOrCreateAutoGauge(
+                      Metric.CLUSTER_NODE_LEADER_COUNT.toString(),
+                      MetricLevel.IMPORTANT,
+                      this,
+                      o -> getLeadershipCountByDatanode(dataNodeId),
+                      Tag.NAME.toString(),
+                      name);
+            });
+  }
+
+  public void removeMetrics() {
+    MetricsService.getInstance()
+        .getMetricManager()
+        .removeGauge(
+            Metric.CONFIG_NODE.toString(),
+            Tag.NAME.toString(),
+            "total",
+            Tag.STATUS.toString(),
+            NodeStatus.Online.toString());
+    MetricsService.getInstance()
+        .getMetricManager()
+        .removeGauge(
+            Metric.DATA_NODE.toString(),
+            Tag.NAME.toString(),
+            "total",
+            Tag.STATUS.toString(),
+            NodeStatus.Online.toString());
+    MetricsService.getInstance()
+        .getMetricManager()
+        .removeGauge(
+            Metric.CONFIG_NODE.toString(),
+            Tag.NAME.toString(),
+            "total",
+            Tag.STATUS.toString(),
+            NodeStatus.Unknown.toString());
+    MetricsService.getInstance()
+        .getMetricManager()
+        .removeGauge(
+            Metric.DATA_NODE.toString(),
+            Tag.NAME.toString(),
+            "total",
+            Tag.STATUS.toString(),
+            NodeStatus.Unknown.toString());
+  }
+
+  private NodeManager getNodeManager() {
+    return configManager.getNodeManager();
+  }
+}
diff --git a/confignode/src/test/resources/confignode1conf/iotdb-metric.yml 
b/confignode/src/test/resources/confignode1conf/iotdb-metric.yml
index cf64f6ad88..e516cf26c4 100644
--- a/confignode/src/test/resources/confignode1conf/iotdb-metric.yml
+++ b/confignode/src/test/resources/confignode1conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15
diff --git a/confignode/src/test/resources/confignode2conf/iotdb-metric.yml 
b/confignode/src/test/resources/confignode2conf/iotdb-metric.yml
index 26fdd95834..c1eba1d2f1 100644
--- a/confignode/src/test/resources/confignode2conf/iotdb-metric.yml
+++ b/confignode/src/test/resources/confignode2conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15
diff --git 
a/confignode/src/test/resources/confignode3conf/iotdb-confignode.properties 
b/confignode/src/test/resources/confignode3conf/iotdb-confignode.properties
index 0fe0c138b9..5fe10d60e2 100644
--- a/confignode/src/test/resources/confignode3conf/iotdb-confignode.properties
+++ b/confignode/src/test/resources/confignode3conf/iotdb-confignode.properties
@@ -28,4 +28,4 @@ 
schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisCon
 system_dir=target/confignode3/system
 data_dirs=target/confignode3/data
 consensus_dir=target/confignode3/consensus
-proc_wal_dir=target/confignode3/proc
\ No newline at end of file
+proc_wal_dir=target/confignode3/proc
diff --git a/confignode/src/test/resources/confignode3conf/iotdb-metric.yml 
b/confignode/src/test/resources/confignode3conf/iotdb-metric.yml
index 85f12c4f23..22a4d3c4cb 100644
--- a/confignode/src/test/resources/confignode3conf/iotdb-metric.yml
+++ b/confignode/src/test/resources/confignode3conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15
diff --git a/docs/UserGuide/Maintenance-Tools/Metric-Tool.md 
b/docs/UserGuide/Maintenance-Tools/Metric-Tool.md
index 9a2035f6de..38b9fa7a71 100644
--- a/docs/UserGuide/Maintenance-Tools/Metric-Tool.md
+++ b/docs/UserGuide/Maintenance-Tools/Metric-Tool.md
@@ -122,9 +122,9 @@ Next, we will choose Prometheus format data as samples to 
describe each kind of
 
 | Metric                    | Tag                                              
                  | level     | Description                                     
                                             | Sample                           
                                            |
 | ------------------------- | 
------------------------------------------------------------------ | --------- 
| 
--------------------------------------------------------------------------------------------
 | ---------------------------------------------------------------------------- 
|
-| cluster_node_leader_count | name="{{ip}}"                                    
                  | important | The count of  ```dataGroupLeader``` on each 
node, which reflects the distribution of leaders | 
cluster_node_leader_count{name="127.0.0.1",} 2.0                             |
+| cluster_node_leader_count | name="{{ip}}:{{port}}"                           
                  | important | The count of  ```dataGroupLeader``` on each 
node, which reflects the distribution of leaders | 
cluster_node_leader_count{name="127.0.0.1",} 2.0                             |
 | cluster_uncommitted_log   | name="{{ip_datagroupHeader}}"                    
                  | important | The count of ```uncommitted_log``` on each node 
in data groups it belongs to                 | 
cluster_uncommitted_log{name="127.0.0.1_Data-127.0.0.1-40010-raftId-0",} 0.0 |
-| cluster_node_status       | 
name="{{ip}}:{{port}}",type="ConfigNode/DataNode"                  | important 
| The current node status, 0=Unkonwn 1=online                                   
               | 
cluster_node_status{name="EndPoint(0.0.0.0:22277)",type="ConfigNode",} 1.0   |
+| cluster_node_status       | 
name="{{ip}}:{{port}}",type="ConfigNode/DataNode"                  | important 
| The current node status, 0=Unkonwn 1=online                                   
               | cluster_node_status{name="0.0.0.0:22277",type="ConfigNode",} 
1.0             |
 | cluster_elect_total       | name="{{ip}}",status="fail/win"                  
                  | important | The count and result (won or failed) of 
elections the node participated in.                  | 
cluster_elect_total{name="127.0.0.1",status="win",} 1.0                      |
 | config_node               | name="total",status="Registered/Online/Unknown"  
                  | core      | The number of registered/online/offline 
confignodes                                          | 
config_node{name="total",status="Online",} 3.0                               |
 | data_node                 | name="total",status="Registered/Online/Unknown"  
                  | core      | The number of registered/online/offline 
datanodes                                            | 
data_node{name="total",status="Registered",} 3.0                             |
diff --git a/docs/zh/UserGuide/Maintenance-Tools/Metric-Tool.md 
b/docs/zh/UserGuide/Maintenance-Tools/Metric-Tool.md
index 91929f5bab..927231bc98 100644
--- a/docs/zh/UserGuide/Maintenance-Tools/Metric-Tool.md
+++ b/docs/zh/UserGuide/Maintenance-Tools/Metric-Tool.md
@@ -120,9 +120,9 @@ IoTDB对外提供JMX和Prometheus格式的监控指标,对于JMX,可以通
 
 | Metric                    | Tag                                              
                  | level     | 说明                                              
            | 示例                                                                
         |
 | ------------------------- | 
------------------------------------------------------------------ | --------- 
| ------------------------------------------------------------- | 
---------------------------------------------------------------------------- |
-| cluster_node_leader_count | name="{{ip}}"                                    
                  | important | 节点上```dataGroupLeader```的数量,用来观察leader是否分布均匀   
| cluster_node_leader_count{name="127.0.0.1",} 2.0                             |
+| cluster_node_leader_count | name="{{ip}}:{{port}}"                           
                  | important | 节点上```dataGroupLeader```的数量,用来观察leader是否分布均匀   
| cluster_node_leader_count{name="127.0.0.1",} 2.0                             |
 | cluster_uncommitted_log   | name="{{ip_datagroupHeader}}"                    
                  | important | 节点```uncommitted_log```的数量                      
          | 
cluster_uncommitted_log{name="127.0.0.1_Data-127.0.0.1-40010-raftId-0",} 0.0 |
-| cluster_node_status       | 
name="{{ip}}:{{port}}",type="ConfigNode/DataNode"                  | important 
| 节点状态,0=Unkonwn 1=online                                   | 
cluster_node_status{name="EndPoint(0.0.0.0:22277)",type="ConfigNode",} 1.0   |
+| cluster_node_status       | 
name="{{ip}}:{{port}}",type="ConfigNode/DataNode"                  | important 
| 节点状态,0=Unkonwn 1=online                                   | 
cluster_node_status{name="0.0.0.0:22277",type="ConfigNode",} 1.0             |
 | cluster_elect_total       | name="{{ip}}",status="fail/win"                  
                  | important | 节点参与选举的次数及结果                                    
    | cluster_elect_total{name="127.0.0.1",status="win",} 1.0                   
   |
 | config_node               | name="total",status="Registered/Online/Unknown"  
                  | core      | 已注册/在线/离线 confignode 的节点数量                      
    | config_node{name="total",status="Online",} 2.0                            
   |
 | data_node                 | name="total",status="Registered/Online/Unknown"  
                  | core      | 已注册/在线/离线 datanode 的节点数量                        
    | data_node{name="total",status="Registered",} 3.0                          
   |
diff --git a/server/src/test/resources/datanode1conf/iotdb-datanode.properties 
b/server/src/test/resources/datanode1conf/iotdb-datanode.properties
index 99d419c9e9..ad13e4a1d9 100644
--- a/server/src/test/resources/datanode1conf/iotdb-datanode.properties
+++ b/server/src/test/resources/datanode1conf/iotdb-datanode.properties
@@ -36,4 +36,4 @@ udf_root_dir=target/datanode1/ext
 tracing_dir=target/datanode1/data/tracing
 consensus_dir=target/datanode1/consensus
 sync_dir=target/datanode1/sync
-timestamp_precision=ms
\ No newline at end of file
+timestamp_precision=ms
diff --git a/server/src/test/resources/datanode1conf/iotdb-metric.yml 
b/server/src/test/resources/datanode1conf/iotdb-metric.yml
index 033d7f74f0..ed4d623d7d 100644
--- a/server/src/test/resources/datanode1conf/iotdb-metric.yml
+++ b/server/src/test/resources/datanode1conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15
diff --git a/server/src/test/resources/datanode2conf/iotdb-datanode.properties 
b/server/src/test/resources/datanode2conf/iotdb-datanode.properties
index dc751f0606..59d1ee3358 100644
--- a/server/src/test/resources/datanode2conf/iotdb-datanode.properties
+++ b/server/src/test/resources/datanode2conf/iotdb-datanode.properties
@@ -35,5 +35,6 @@ index_root_dir=target/datanode2/data/index
 udf_root_dir=target/datanode2/ext
 tracing_dir=target/datanode2/data/tracing
 consensus_dir=target/datanode2/consensus
+timestamp_precision=ms
 sync_dir=target/datanode2/sync
-timestamp_precision=ms
\ No newline at end of file
+timestamp_precision=ms
diff --git a/server/src/test/resources/datanode2conf/iotdb-metric.yml 
b/server/src/test/resources/datanode2conf/iotdb-metric.yml
index 9225877b9a..ce73290f9d 100644
--- a/server/src/test/resources/datanode2conf/iotdb-metric.yml
+++ b/server/src/test/resources/datanode2conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15
diff --git a/server/src/test/resources/datanode3conf/iotdb-metric.yml 
b/server/src/test/resources/datanode3conf/iotdb-metric.yml
index adc2c4ca53..2102c2ce5a 100644
--- a/server/src/test/resources/datanode3conf/iotdb-metric.yml
+++ b/server/src/test/resources/datanode3conf/iotdb-metric.yml
@@ -50,4 +50,4 @@ ioTDBReporterConfig:
   password: root
   maxConnectionNumber: 3
   database: _metric
-  pushPeriodInSecond: 15
\ No newline at end of file
+  pushPeriodInSecond: 15

Reply via email to