From 4182c013c815f1397b4d2bbdd1451d6b5deba0b8 Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Sat, 25 May 2019 15:09:10 +0800 Subject: [PATCH] dashboard: Filter internal virtual resources in MetricFetcher - also fix pom.xml to suppress warnings Signed-off-by: Eric Zhao --- sentinel-dashboard/pom.xml | 1 + .../dashboard/metric/MetricFetcher.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sentinel-dashboard/pom.xml b/sentinel-dashboard/pom.xml index dca0cfc8..b8bafb10 100755 --- a/sentinel-dashboard/pom.xml +++ b/sentinel-dashboard/pom.xml @@ -139,6 +139,7 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true com.alibaba.csp.sentinel.dashboard.DashboardApplication diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java index ffcfc621..2c032249 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java @@ -19,6 +19,7 @@ import java.net.ConnectException; import java.net.SocketTimeoutException; import java.nio.charset.Charset; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -34,6 +35,7 @@ import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; +import com.alibaba.csp.sentinel.Constants; import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; import com.alibaba.csp.sentinel.config.SentinelConfig; import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; @@ -322,7 +324,10 @@ public class MetricFetcher { for (String line : lines) { try { MetricNode node = MetricNode.fromThinString(line); - /** + if (shouldFilterOut(node.getResource())) { + continue; + } + /* * aggregation metrics by app_resource_timeSecond, ignore ip and port. */ String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp()); @@ -355,6 +360,16 @@ public class MetricFetcher { return app + "__" + resource + "__" + (timestamp / 1000); } + private boolean shouldFilterOut(String resource) { + return RES_EXCLUSION_SET.contains(resource); + } + + private static final Set RES_EXCLUSION_SET = new HashSet() {{ + add(Constants.TOTAL_IN_RESOURCE_NAME); + add(Constants.SYSTEM_LOAD_RESOURCE_NAME); + add(Constants.CPU_USAGE_RESOURCE_NAME); + }}; + }