[SCB-2556]support report monitor data from metrics module (#3052)

diff --git a/huawei-cloud/dashboard/pom.xml b/huawei-cloud/dashboard/pom.xml
index 76f350c..6a31223 100644
--- a/huawei-cloud/dashboard/pom.xml
+++ b/huawei-cloud/dashboard/pom.xml
@@ -44,12 +44,21 @@
             <artifactId>registry-service-center</artifactId>
         </dependency>
         <dependency>
-            <groupId>com.netflix.hystrix</groupId>
-            <artifactId>hystrix-core</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.servicecomb</groupId>
             <artifactId>dashboard-client</artifactId>
         </dependency>
+
+        <!-- optional dependencies -->
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-bizkeeper</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>metrics-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- optional dependencies -->
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/ConsoleMonitorDataPublisher.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/ConsoleMonitorDataPublisher.java
deleted file mode 100644
index 324f23d..0000000
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/ConsoleMonitorDataPublisher.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.servicecomb.huaweicloud.dashboard.monitor;
-
-import io.vertx.core.json.Json;
-import org.apache.servicecomb.foundation.common.event.EventManager;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.event.ConsoleMonitorDataEvent;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDaraProvider;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataPublisher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConsoleMonitorDataPublisher implements MonitorDataPublisher {
-  private static final int END_INDEX = 100;
-
-  private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleMonitorDataPublisher.class);
-
-  @Override
-  public void publish(MonitorDaraProvider provider) {
-    Object data = provider.getData();
-    if (data == null) {
-      return;
-    }
-    String reqString = Json.encode(data);
-    LOGGER.info(reqString.length() > END_INDEX ? reqString.substring(0, END_INDEX) : reqString);
-    EventManager.post(new ConsoleMonitorDataEvent(reqString));
-  }
-}
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DataFactory.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DataFactory.java
index 3dd2883..67f94c2 100644
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DataFactory.java
+++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DataFactory.java
@@ -88,7 +88,9 @@
 
   void sendData() {
     for (MonitorDaraProvider provider : this.dataProviders) {
-      this.publisher.publish(provider);
+      if (provider.enabled()) {
+        this.publisher.publish(provider);
+      }
     }
   }
 }
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java
index 76f2998..70b6e44 100644
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java
+++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java
@@ -33,7 +33,6 @@
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.dashboard.client.DashboardAddressManager;
 import org.apache.servicecomb.dashboard.client.DashboardClient;
-import org.apache.servicecomb.dashboard.client.model.MonitorData;
 import org.apache.servicecomb.deployment.Deployment;
 import org.apache.servicecomb.deployment.SystemBootstrapInfo;
 import org.apache.servicecomb.foundation.auth.AuthHeaderProvider;
@@ -45,12 +44,8 @@
 import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant;
 import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDaraProvider;
 import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataPublisher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class DefaultMonitorDataPublisher implements MonitorDataPublisher {
-  private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMonitorDataPublisher.class);
-
   private static final String SSL_KEY = "mc.consumer";
 
   private DashboardClient dashboardClient;
@@ -124,10 +119,6 @@
 
   @Override
   public void publish(MonitorDaraProvider provider) {
-    MonitorData data = provider.getData();
-    if (data == null) {
-      return;
-    }
-    dashboardClient.sendData(provider.getURL(), data);
+    dashboardClient.sendData(provider.getURL(), provider.getData());
   }
 }
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java
index b883b37..7f0c9dd 100644
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java
+++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java
@@ -17,87 +17,40 @@
 
 package org.apache.servicecomb.huaweicloud.dashboard.monitor;
 
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.MemoryUsage;
-import java.lang.management.OperatingSystemMXBean;
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.ThreadMXBean;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.servicecomb.dashboard.client.model.InterfaceInfo;
 import org.apache.servicecomb.dashboard.client.model.MonitorData;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.CPUMonitorCalc;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant;
 import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDaraProvider;
-import org.apache.servicecomb.registry.api.registry.Microservice;
-import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
 
+import com.netflix.config.DynamicPropertyFactory;
 import com.netflix.hystrix.HystrixCircuitBreaker;
 import com.netflix.hystrix.HystrixCommandMetrics;
 import com.netflix.hystrix.HystrixEventType;
 
+/**
+ * This provider depends on bizkeeper. Because Bizkeeper depends on Hystrix
+ * and it is not in maintainence, will keep it here for compatible reason.
+ */
 public class HealthMonitorDataProvider implements MonitorDaraProvider {
   @Override
-  public String getURL() {
-    return String.format(MonitorConstant.MONITORS_URI, RegistryUtils.getMicroservice().getServiceName());
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty("servicecomb.monitor.provider.bizkeeper.enabled", false)
+        .get();
   }
 
   @Override
-  public MonitorData getData() {
-    return getMonitorData();
-  }
-
-  private MonitorData getMonitorData() {
+  public void extractInterfaceInfo(MonitorData monitorData) {
     Collection<HystrixCommandMetrics> instances = HystrixCommandMetrics.getInstances();
-    MonitorData monitorData = new MonitorData();
-    Microservice microservice = RegistryUtils.getMicroservice();
-    MicroserviceInstance microserviceInstance = RegistryUtils.getMicroserviceInstance();
-    monitorData.setAppId(microservice.getAppId());
-    monitorData.setName(microservice.getServiceName());
-    monitorData.setVersion(microservice.getVersion());
-    monitorData.setServiceId(microservice.getServiceId());
-    monitorData.setInstance(microserviceInstance.getHostName());
-    monitorData.setInstanceId(microserviceInstance.getInstanceId());
-    exactProcessInfo(monitorData);
     if (instances.isEmpty()) {
-      return monitorData;
+      return;
     }
     for (HystrixCommandMetrics instance : instances) {
       appendInterfaceInfo(monitorData, instance);
     }
-    return monitorData;
-  }
-
-  private void exactProcessInfo(MonitorData monitorData) {
-    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
-    MemoryUsage memoryHeapUsage = memoryMXBean.getHeapMemoryUsage();
-    MemoryUsage memoryNonHeapUsage = memoryMXBean.getNonHeapMemoryUsage();
-    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
-    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
-    int threadCount = threadMXBean.getThreadCount();
-    OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
-
-    double cpu = operatingSystemMXBean.getSystemLoadAverage();
-    monitorData.setCpu(CPUMonitorCalc.getInstance().getProcessCpu());
-    monitorData.setLoadAverage(cpu);
-    monitorData.setThreadCount(threadCount);
-    monitorData.setUptime(runtimeMXBean.getUptime());
-
-    Map<String, Long> memoryInfo = new HashMap<>();
-    memoryInfo.put("heapInit", memoryHeapUsage.getInit());
-    memoryInfo.put("headMax", memoryHeapUsage.getMax());
-    memoryInfo.put("heapCommit", memoryHeapUsage.getCommitted());
-    memoryInfo.put("heapUsed", memoryHeapUsage.getUsed());
-    memoryInfo.put("nonHeapInit", memoryNonHeapUsage.getInit());
-    memoryInfo.put("nonHeapCommit", memoryNonHeapUsage.getCommitted());
-    memoryInfo.put("nonHeapUsed", memoryNonHeapUsage.getUsed());
-    monitorData.setMemory(memoryInfo);
   }
 
   private void appendInterfaceInfo(MonitorData monitorData, HystrixCommandMetrics metrics) {
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProvider.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProvider.java
new file mode 100644
index 0000000..6c0b4c7
--- /dev/null
+++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProvider.java
@@ -0,0 +1,201 @@
+/*
+ * 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.servicecomb.huaweicloud.dashboard.monitor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.servicecomb.dashboard.client.model.InterfaceInfo;
+import org.apache.servicecomb.dashboard.client.model.MonitorData;
+import org.apache.servicecomb.foundation.common.event.EventManager;
+import org.apache.servicecomb.foundation.metrics.PolledEvent;
+import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDaraProvider;
+import org.apache.servicecomb.metrics.core.meter.invocation.MeterInvocationConst;
+import org.apache.servicecomb.metrics.core.publish.PublishModelFactory;
+import org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel;
+import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf;
+import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup;
+import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups;
+import org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo;
+
+import com.google.common.eventbus.Subscribe;
+import com.netflix.config.DynamicPropertyFactory;
+import com.netflix.spectator.api.Meter;
+
+/**
+ * Monitor data based on metrics-core module.
+ */
+public class MetricsMonitorDataProvider implements MonitorDaraProvider {
+
+  public static final String CODE_SUCCESS = "2[0-9]{2}";
+
+  public static final String CODE_TIMEOUT = "408";
+
+  public static final String NAME_PROVIDER = "Provider.";
+
+  public static final String NAME_CONSUMER = "Consumer.";
+
+  private volatile List<Meter> meters = null;
+
+  public MetricsMonitorDataProvider() {
+    EventManager.register(this);
+  }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty("servicecomb.monitor.provider.metrics.enabled", true)
+        .get();
+  }
+
+  @Override
+  public void extractInterfaceInfo(MonitorData monitorData) {
+    if (meters == null) {
+      return;
+    }
+    PublishModelFactory factory = new PublishModelFactory(meters);
+    DefaultPublishModel model = factory.createDefaultPublishModel();
+
+    Map<String, InterfaceInfo> combinedResults = new HashMap<>();
+    extractProviderInfo(model, combinedResults);
+    extractConsumerInfo(model, combinedResults);
+    extractEdgeInfo(model, combinedResults);
+    combinedResults.forEach((k, v) -> {
+      v.setFailureRate(v.getTotal() == 0 ? 0 : v.getFailure() / (double) v.getTotal());
+      monitorData.addInterfaceInfo(v);
+    });
+  }
+
+  private void extractProviderInfo(DefaultPublishModel model, Map<String, InterfaceInfo> combinedResults) {
+    OperationPerfGroups producerPerf = model.getProducer().getOperationPerfGroups();
+    if (producerPerf == null) {
+      return;
+    }
+
+    for (Map<String, OperationPerfGroup> statusMap : producerPerf.getGroups().values()) {
+      for (OperationPerfGroup perfGroup : statusMap.values()) {
+        for (int i = 0; i < perfGroup.getOperationPerfs().size(); i++) {
+          OperationPerf operationPerf = perfGroup.getOperationPerfs().get(i);
+          PerfInfo stageTotal = operationPerf.findStage(MeterInvocationConst.STAGE_TOTAL);
+          String name = NAME_PROVIDER + operationPerf.getOperation();
+          InterfaceInfo interfaceInfo = combinedResults.computeIfAbsent(name,
+              k -> {
+                InterfaceInfo obj = new InterfaceInfo();
+                obj.setName(name);
+                return obj;
+              });
+          // dashboard calculates the latest 10 seconds, different with metrics cycle.
+          interfaceInfo.setTotal(
+              doubleToInt(interfaceInfo.getTotal() + 10 * stageTotal.getTps()));
+          if (perfGroup.getStatus().matches(CODE_SUCCESS)) {
+            interfaceInfo.setQps(stageTotal.getTps());
+            interfaceInfo.setLatency(doubleToInt(stageTotal.calcMsLatency()));
+          } else {
+            interfaceInfo.setFailure(
+                doubleToInt(interfaceInfo.getTotal() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            if (perfGroup.getStatus().equals(CODE_TIMEOUT)) {
+              interfaceInfo.setCountTimeout(
+                  doubleToInt(interfaceInfo.getCountTimeout() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            }
+          }
+        }
+      }
+    }
+  }
+
+  private void extractEdgeInfo(DefaultPublishModel model, Map<String, InterfaceInfo> combinedResults) {
+    OperationPerfGroups edgePerf = model.getEdge().getOperationPerfGroups();
+    if (edgePerf == null) {
+      return;
+    }
+    for (Map<String, OperationPerfGroup> statusMap : edgePerf.getGroups().values()) {
+      for (OperationPerfGroup perfGroup : statusMap.values()) {
+        for (int i = 0; i < perfGroup.getOperationPerfs().size(); i++) {
+          OperationPerf operationPerf = perfGroup.getOperationPerfs().get(i);
+          PerfInfo stageTotal = operationPerf.findStage(MeterInvocationConst.STAGE_TOTAL);
+          String name = NAME_CONSUMER + operationPerf.getOperation();
+          InterfaceInfo interfaceInfo = combinedResults.computeIfAbsent(name,
+              k -> {
+                InterfaceInfo obj = new InterfaceInfo();
+                obj.setName(name);
+                return obj;
+              });
+          // dashboard calculates the latest 10 seconds, different with metrics cycle.
+          interfaceInfo.setTotal(
+              doubleToInt(interfaceInfo.getTotal() + 10 * stageTotal.getTps()));
+          if (perfGroup.getStatus().matches(CODE_SUCCESS)) {
+            interfaceInfo.setQps(stageTotal.getTps());
+            interfaceInfo.setLatency(doubleToInt(stageTotal.calcMsLatency()));
+          } else {
+            interfaceInfo.setFailure(
+                doubleToInt(interfaceInfo.getTotal() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            if (perfGroup.getStatus().equals(CODE_TIMEOUT)) {
+              interfaceInfo.setCountTimeout(
+                  doubleToInt(interfaceInfo.getCountTimeout() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            }
+          }
+        }
+      }
+    }
+  }
+
+  private void extractConsumerInfo(DefaultPublishModel model, Map<String, InterfaceInfo> combinedResults) {
+    OperationPerfGroups consumerPerf = model.getConsumer().getOperationPerfGroups();
+    if (consumerPerf == null) {
+      return;
+    }
+    for (Map<String, OperationPerfGroup> statusMap : consumerPerf.getGroups().values()) {
+      for (OperationPerfGroup perfGroup : statusMap.values()) {
+        for (int i = 0; i < perfGroup.getOperationPerfs().size(); i++) {
+          OperationPerf operationPerf = perfGroup.getOperationPerfs().get(i);
+          PerfInfo stageTotal = operationPerf.findStage(MeterInvocationConst.STAGE_TOTAL);
+          String name = NAME_CONSUMER + operationPerf.getOperation();
+          InterfaceInfo interfaceInfo = combinedResults.computeIfAbsent(name,
+              k -> {
+                InterfaceInfo obj = new InterfaceInfo();
+                obj.setName(name);
+                return obj;
+              });
+          // dashboard calculates the latest 10 seconds, different with metrics cycle.
+          interfaceInfo.setTotal(
+              doubleToInt(interfaceInfo.getTotal() + 10 * stageTotal.getTps()));
+          if (perfGroup.getStatus().matches(CODE_SUCCESS)) {
+            interfaceInfo.setQps(stageTotal.getTps());
+            interfaceInfo.setLatency(doubleToInt(stageTotal.calcMsLatency()));
+          } else {
+            interfaceInfo.setFailure(
+                doubleToInt(interfaceInfo.getTotal() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            if (perfGroup.getStatus().equals(CODE_TIMEOUT)) {
+              interfaceInfo.setCountTimeout(
+                  doubleToInt(interfaceInfo.getCountTimeout() + stageTotal.getMsTotalTime() * stageTotal.getTps()));
+            }
+          }
+        }
+      }
+    }
+  }
+
+  private int doubleToInt(Double d) {
+    return d.intValue();
+  }
+
+  @Subscribe
+  public void onPolledEvent(PolledEvent event) {
+    this.meters = event.getMeters();
+  }
+}
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/event/ConsoleMonitorDataEvent.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/event/ConsoleMonitorDataEvent.java
deleted file mode 100644
index 73a68f5..0000000
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/event/ConsoleMonitorDataEvent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.servicecomb.huaweicloud.dashboard.monitor.event;
-
-public class ConsoleMonitorDataEvent {
-  private String jsonData;
-
-  public ConsoleMonitorDataEvent(String jsonData) {
-    this.setJsonData(jsonData);
-  }
-
-  public String getJsonData() {
-    return jsonData;
-  }
-
-  public void setJsonData(String jsonData) {
-    this.jsonData = jsonData;
-  }
-}
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/model/MonitorDaraProvider.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/model/MonitorDaraProvider.java
index 3d3ddda..bfe2155 100644
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/model/MonitorDaraProvider.java
+++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/model/MonitorDaraProvider.java
@@ -17,10 +17,73 @@
 
 package org.apache.servicecomb.huaweicloud.dashboard.monitor.model;
 
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryUsage;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.RuntimeMXBean;
+import java.lang.management.ThreadMXBean;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.servicecomb.dashboard.client.model.MonitorData;
+import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.CPUMonitorCalc;
+import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant;
+import org.apache.servicecomb.registry.api.registry.Microservice;
+import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
 
 public interface MonitorDaraProvider {
-  String getURL();
+  boolean enabled();
 
-  MonitorData getData();
+  default String getURL() {
+    return String.format(MonitorConstant.MONITORS_URI, RegistryUtils.getMicroservice().getServiceName());
+  }
+
+  default void extractServiceInfo(MonitorData monitorData) {
+    Microservice microservice = RegistryUtils.getMicroservice();
+    MicroserviceInstance microserviceInstance = RegistryUtils.getMicroserviceInstance();
+    monitorData.setAppId(microservice.getAppId());
+    monitorData.setName(microservice.getServiceName());
+    monitorData.setVersion(microservice.getVersion());
+    monitorData.setServiceId(microservice.getServiceId());
+    monitorData.setInstance(microserviceInstance.getHostName());
+    monitorData.setInstanceId(microserviceInstance.getInstanceId());
+  }
+
+  default void exactProcessInfo(MonitorData monitorData) {
+    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
+    MemoryUsage memoryHeapUsage = memoryMXBean.getHeapMemoryUsage();
+    MemoryUsage memoryNonHeapUsage = memoryMXBean.getNonHeapMemoryUsage();
+    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
+    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
+    int threadCount = threadMXBean.getThreadCount();
+    OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
+
+    double cpu = operatingSystemMXBean.getSystemLoadAverage();
+    monitorData.setCpu(CPUMonitorCalc.getInstance().getProcessCpu());
+    monitorData.setLoadAverage(cpu);
+    monitorData.setThreadCount(threadCount);
+    monitorData.setUptime(runtimeMXBean.getUptime());
+
+    Map<String, Long> memoryInfo = new HashMap<>();
+    memoryInfo.put("heapInit", memoryHeapUsage.getInit());
+    memoryInfo.put("headMax", memoryHeapUsage.getMax());
+    memoryInfo.put("heapCommit", memoryHeapUsage.getCommitted());
+    memoryInfo.put("heapUsed", memoryHeapUsage.getUsed());
+    memoryInfo.put("nonHeapInit", memoryNonHeapUsage.getInit());
+    memoryInfo.put("nonHeapCommit", memoryNonHeapUsage.getCommitted());
+    memoryInfo.put("nonHeapUsed", memoryNonHeapUsage.getUsed());
+    monitorData.setMemory(memoryInfo);
+  }
+
+  void extractInterfaceInfo(MonitorData monitorData);
+
+  default MonitorData getData() {
+    MonitorData monitorData = new MonitorData();
+    extractServiceInfo(monitorData);
+    exactProcessInfo(monitorData);
+    extractInterfaceInfo(monitorData);
+    return monitorData;
+  }
 }
diff --git a/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml b/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
index 89a1599..bd26a5a 100644
--- a/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
+++ b/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
@@ -20,6 +20,7 @@
 
     <bean id="monitorStarterListener" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.MonitorBootListener"></bean>
     <bean id="dataFactory" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.DataFactory"></bean>
-    <bean id="healthmonitorDataProvider" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.HealthMonitorDataProvider"></bean>
+    <bean id="healthMonitorDataProvider" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.HealthMonitorDataProvider"></bean>
+    <bean id="metricsMonitorDataProvider" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.MetricsMonitorDataProvider"></bean>
     <bean id="defaultMonitorDataPublisher" class="org.apache.servicecomb.huaweicloud.dashboard.monitor.DefaultMonitorDataPublisher"></bean>
 </beans>
diff --git a/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDaraProviderTest.java b/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDaraProviderTest.java
new file mode 100644
index 0000000..c3a1a55
--- /dev/null
+++ b/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDaraProviderTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.huaweicloud.dashboard.monitor;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class MetricsMonitorDaraProviderTest {
+  @Test
+  public void testCodeMatch() {
+    Assertions.assertTrue("200".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
+    Assertions.assertTrue("202".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
+    Assertions.assertFalse("2002".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
+    Assertions.assertFalse("400".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
+  }
+}