瀏覽代碼

dashboard: Filter internal virtual resources in MetricFetcher

- also fix pom.xml to suppress warnings

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 年之前
父節點
當前提交
4182c013c8
共有 2 個文件被更改,包括 17 次插入1 次删除
  1. +1
    -0
      sentinel-dashboard/pom.xml
  2. +16
    -1
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java

+ 1
- 0
sentinel-dashboard/pom.xml 查看文件

@@ -139,6 +139,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<fork>true</fork>
<mainClass>com.alibaba.csp.sentinel.dashboard.DashboardApplication</mainClass>


+ 16
- 1
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<String> RES_EXCLUSION_SET = new HashSet<String>() {{
add(Constants.TOTAL_IN_RESOURCE_NAME);
add(Constants.SYSTEM_LOAD_RESOURCE_NAME);
add(Constants.CPU_USAGE_RESOURCE_NAME);
}};

}




Loading…
取消
儲存