You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/06/15 03:07:53 UTC

[GitHub] [iotdb] SpriCoder opened a new pull request, #6291: [IOTDB-3433] add metric for cluster.

SpriCoder opened a new pull request, #6291:
URL: https://github.com/apache/iotdb/pull/6291

   See more details: https://issues.apache.org/jira/browse/IOTDB-3433


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898650583


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {

Review Comment:
   Get it.



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {
+    Set<RegionGroup> regionGroups = new HashSet<>();
+    for (Map.Entry<String, StorageGroupPartitionTable> entry :
+        storageGroupPartitionTables.entrySet()) {
+      regionGroups.addAll(entry.getValue().getRegion(type));
+    }
+    int result = regionGroups.size();
+    // statistic
+    Map<TDataNodeLocation, Integer> dataNodeLocationIntegerMap = new HashMap<>();

Review Comment:
   get 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#issuecomment-1157141711

   In Grafana, for confignode:
   ![image](https://user-images.githubusercontent.com/46039728/173973503-f6f25cd3-38b5-4a60-8b81-4255f75ad860.png)
   
   for datanode:
   ![image](https://user-images.githubusercontent.com/46039728/173973565-3cd99c3a-e268-4131-8857-247bf3b3ae57.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898650090


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),

Review Comment:
   Ok, I will update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898650830


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {
+    Set<RegionGroup> regionGroups = new HashSet<>();
+    for (Map.Entry<String, StorageGroupPartitionTable> entry :
+        storageGroupPartitionTables.entrySet()) {
+      regionGroups.addAll(entry.getValue().getRegion(type));
+    }
+    int result = regionGroups.size();
+    // statistic
+    Map<TDataNodeLocation, Integer> dataNodeLocationIntegerMap = new HashMap<>();
+    for (RegionGroup regionGroup : regionGroups) {
+      TRegionReplicaSet regionReplicaSet = regionGroup.getReplicaSet();
+      List<TDataNodeLocation> dataNodeLocations = regionReplicaSet.getDataNodeLocations();
+      for (TDataNodeLocation dataNodeLocation : dataNodeLocations) {
+        if (!dataNodeLocationIntegerMap.containsKey(dataNodeLocation)) {
+          dataNodeLocationIntegerMap.put(dataNodeLocation, 0);
+        }
+        dataNodeLocationIntegerMap.put(
+            dataNodeLocation, dataNodeLocationIntegerMap.get(dataNodeLocation) + 1);
+      }
+    }
+    for (Map.Entry<TDataNodeLocation, Integer> entry : dataNodeLocationIntegerMap.entrySet()) {
+      TDataNodeLocation dataNodeLocation = entry.getKey();
+      String name =
+          "EndPoint("
+              + dataNodeLocation.getExternalEndPoint().ip
+              + ":"
+              + dataNodeLocation.getExternalEndPoint().port
+              + ")";
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.REGION.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              type.toString())
+          .set(dataNodeLocationIntegerMap.get(dataNodeLocation));

Review Comment:
   this is shown in region on node.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898650504


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),
+              MetricLevel.CORE,
+              storageGroupPartitionTables,
+              Map::size,
+              Tag.NAME.toString(),
+              "number");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   I use type tag to filter which is more convenience.



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),
+              MetricLevel.CORE,
+              storageGroupPartitionTables,
+              Map::size,
+              Tag.NAME.toString(),
+              "number");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.IMPORTANT,
+              this,
+              o -> o.getTotalRegionCountAndUpdateMetric(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              "total",
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   I use type tag to filter which is more convenience.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr merged pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
xingtanzjr merged PR #6291:
URL: https://github.com/apache/iotdb/pull/6291


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#issuecomment-1156554005

   @wangchao316 PTAL!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898650944


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   I use type tag to filter which is more convenience.



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   I use type tag to filter which is more convenience.



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.DataRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.DataRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.SLOT.toString(),
+              MetricLevel.NORMAL,
+              schemaPartitionTable,
+              o -> o.getSchemaPartitionMap().size(),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              "schemaSlotNumber");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.SLOT.toString(),
+              MetricLevel.NORMAL,
+              dataPartitionTable,
+              o -> o.getDataPartitionMap().size(),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              "dataSlotNumber");
+    }

Review Comment:
   get



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] SpriCoder commented on pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
SpriCoder commented on PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#issuecomment-1156151651

   Get it, I will add some related metrics.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
CRZbulabula commented on code in PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#discussion_r898626874


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),

Review Comment:
   Metric.STORAGEGROUP?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),
+              MetricLevel.CORE,
+              storageGroupPartitionTables,
+              Map::size,
+              Tag.NAME.toString(),
+              "number");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.IMPORTANT,
+              this,
+              o -> o.getTotalRegionCountAndUpdateMetric(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              "total",
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   Metric.DATAREGION?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {

Review Comment:
   Split this interface into getTotalRegionCount and UpdateMetric might better, I wanna use getTotalRegionCount later~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   Metric.DATAREGION?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.SchemaRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.SchemaRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),
+              MetricLevel.NORMAL,
+              this,
+              o -> o.getRegionCount(TConsensusGroupType.DataRegion),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              TConsensusGroupType.DataRegion.toString());
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.SLOT.toString(),
+              MetricLevel.NORMAL,
+              schemaPartitionTable,
+              o -> o.getSchemaPartitionMap().size(),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              "schemaSlotNumber");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.SLOT.toString(),
+              MetricLevel.NORMAL,
+              dataPartitionTable,
+              o -> o.getDataPartitionMap().size(),
+              Tag.NAME.toString(),
+              storageGroupName,
+              Tag.TYPE.toString(),
+              "dataSlotNumber");
+    }

Review Comment:
   The name "SLOT" will be update later, please add a "TODO"



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -98,6 +105,42 @@ public PartitionInfo() {
     this.deletedRegionSet = Collections.synchronizedSet(new HashSet<>());
   }
 
+  public void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.PARTITION_TABLE.toString(),
+              MetricLevel.CORE,
+              storageGroupPartitionTables,
+              Map::size,
+              Tag.NAME.toString(),
+              "number");
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   Metric.SCHEMAREGION?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {
+    Set<RegionGroup> regionGroups = new HashSet<>();
+    for (Map.Entry<String, StorageGroupPartitionTable> entry :
+        storageGroupPartitionTables.entrySet()) {
+      regionGroups.addAll(entry.getValue().getRegion(type));
+    }
+    int result = regionGroups.size();
+    // statistic
+    Map<TDataNodeLocation, Integer> dataNodeLocationIntegerMap = new HashMap<>();

Review Comment:
   Add java doc to display what this Map stands for



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -484,6 +529,54 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(
     return storageGroupPartitionTables.get(storageGroup).getSortedRegionSlotsCounter(type);
   }
 
+  /**
+   * Get total region number and update metric
+   *
+   * @param type SchemaRegion or DataRegion
+   * @return the number of SchemaRegion or DataRegion
+   */
+  private int getTotalRegionCountAndUpdateMetric(TConsensusGroupType type) {
+    Set<RegionGroup> regionGroups = new HashSet<>();
+    for (Map.Entry<String, StorageGroupPartitionTable> entry :
+        storageGroupPartitionTables.entrySet()) {
+      regionGroups.addAll(entry.getValue().getRegion(type));
+    }
+    int result = regionGroups.size();
+    // statistic
+    Map<TDataNodeLocation, Integer> dataNodeLocationIntegerMap = new HashMap<>();
+    for (RegionGroup regionGroup : regionGroups) {
+      TRegionReplicaSet regionReplicaSet = regionGroup.getReplicaSet();
+      List<TDataNodeLocation> dataNodeLocations = regionReplicaSet.getDataNodeLocations();
+      for (TDataNodeLocation dataNodeLocation : dataNodeLocations) {
+        if (!dataNodeLocationIntegerMap.containsKey(dataNodeLocation)) {
+          dataNodeLocationIntegerMap.put(dataNodeLocation, 0);
+        }
+        dataNodeLocationIntegerMap.put(
+            dataNodeLocation, dataNodeLocationIntegerMap.get(dataNodeLocation) + 1);
+      }
+    }
+    for (Map.Entry<TDataNodeLocation, Integer> entry : dataNodeLocationIntegerMap.entrySet()) {
+      TDataNodeLocation dataNodeLocation = entry.getKey();
+      String name =
+          "EndPoint("
+              + dataNodeLocation.getExternalEndPoint().ip
+              + ":"
+              + dataNodeLocation.getExternalEndPoint().port
+              + ")";
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateGauge(
+              Metric.REGION.toString(),
+              MetricLevel.IMPORTANT,
+              Tag.NAME.toString(),
+              name,
+              Tag.TYPE.toString(),
+              type.toString())
+          .set(dataNodeLocationIntegerMap.get(dataNodeLocation));

Review Comment:
   Comments may require another screenshot to show this monitoring indicators



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -70,6 +81,57 @@ public StorageGroupPartitionTable() {
 
     this.schemaPartitionTable = new SchemaPartitionTable();
     this.dataPartitionTable = new DataPartitionTable();
+
+    addMetrics();
+  }
+
+  private void addMetrics() {
+    if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
+      MetricsService.getInstance()
+          .getMetricManager()
+          .getOrCreateAutoGauge(
+              Metric.REGION.toString(),

Review Comment:
   Metric.SCHEMAREGION?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] wangchao316 commented on pull request #6291: [IOTDB-3433] add metric for cluster.

Posted by GitBox <gi...@apache.org>.
wangchao316 commented on PR #6291:
URL: https://github.com/apache/iotdb/pull/6291#issuecomment-1156148113

   we need add metric for region distribution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org