diff --git a/server/agg/agg-boot/src/main/java/io/holoinsight/server/agg/v1/executor/executor/MetricStorageOutput.java b/server/agg/agg-boot/src/main/java/io/holoinsight/server/agg/v1/executor/executor/MetricStorageOutput.java index a1696cfb8..bd07acc90 100644 --- a/server/agg/agg-boot/src/main/java/io/holoinsight/server/agg/v1/executor/executor/MetricStorageOutput.java +++ b/server/agg/agg-boot/src/main/java/io/holoinsight/server/agg/v1/executor/executor/MetricStorageOutput.java @@ -39,7 +39,6 @@ public String type() { @Override public void write(Batch batch) { - log.info("xxx"); WriteMetricsParam param = new WriteMetricsParam(); param.setTenant(batch.key.getTenant()); List points = new ArrayList<>(batch.groups.size()); diff --git a/server/agg/agg-boot/src/main/java/temp.groovy b/server/agg/agg-boot/src/main/java/temp.groovy deleted file mode 100644 index 5c6fcf212..000000000 --- a/server/agg/agg-boot/src/main/java/temp.groovy +++ /dev/null @@ -1,124 +0,0 @@ -import com.alibaba.fastjson.JSON -import io.holoinsight.server.common.dao.entity.AggTaskV1DO -import io.holoinsight.server.common.dao.entity.AggTaskV1DOExample -import io.holoinsight.server.common.dao.mapper.AggTaskV1DOMapper - -// sh /home/admin/logs/api/groovy/execute - -def mapper = ctx.getBean(AggTaskV1DOMapper.class) -def json = ''' -{ - "aggId": "k8s_pod_system_5s", - "version": 1, - "partitionKeys": [], - "select": { - "items": [ - { - "agg": { - "type": "COUNT" - }, - "elect": "k8s_pod_cpu_util_5s.value", - "as": "count" - }, - { - "agg": { - "type": "AVG" - }, - "elect": "k8s_pod_cpu_util_5s.value", - "as": "cpu_util" - } - ] - }, - "from": { - "type": "metrics", - "metrics": { - "metrics": [ - "k8s_pod_cpu_util_5s" - ] - }, - "completeness": { - "mode": "DATA", - "dimTable": "%s_server", - "groupBy": { - "items": [ - { - "tag": "app", - "as": "app" - }, - { - "tag": "_cluster", - "as": "cluster" - } - ] - }, - "keepTargetKeys": [ - "namespace", - "name" - ] - } - }, - "where": { - }, - "groupBy": { - "keyLimit": 1000, - "items": [ - { - "tag": "tenant" - }, - { - "tag": "workspace" - }, - { - "tag": "app" - } - ] - }, - "window": { - "interval": 5000 - }, - "output": { - "items": [ - { - "type": "TSDB", - "name": "k8s_pod_%s_5s_agg", - "fields": [ - { - "name": "cpu_util", - "expression": "cpu_util" - }, - { - "name": "count", - "expression": "count" - } - ] - } - ] - } -} -''' - -def aggId = JSON.parseObject(json).getString("aggId") - -def example = AggTaskV1DOExample.newAndCreateCriteria() - .andAggIdEqualTo(aggId) // - .andDeletedEqualTo(0) // - .example() - -def d = mapper.selectOneByExampleWithBLOBs(example) -if (d == null) { - d = new AggTaskV1DO() - d.gmtCreate = new Date() - d.gmtModified = new Date() - d.aggId = aggId - d.json = json - d.version = 0 - d.deleted = 0 - mapper.insert(d) -} else { - d.gmtModified = new Date() - d.json = json - d.version++ - mapper.updateByPrimaryKeyWithBLOBs(d) -} - -return d.version diff --git a/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggDispatcher.java b/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggDispatcher.java index 605da9e0f..d16c18f0d 100644 --- a/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggDispatcher.java +++ b/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggDispatcher.java @@ -162,7 +162,8 @@ public void dispatch(AuthInfo authInfo, WriteMetricsRequestV4 request) { ProducerRecord record = new ProducerRecord<>(aggProperties.getTopic(), aggKey, aggTaskValue.build()); kafkaProducer.send(record); - StatUtils.KAFKA_SEND.add(StringsKey.of("v4"), Stats.V_1); + StatUtils.KAFKA_SEND.add(StringsKey.of("v4"), + new long[] {1, aggTaskValue.getInDataNodesCount()}); } } } @@ -204,7 +205,8 @@ public void dispatch(AuthInfo authInfo, WriteMetricsRequestV1 request) { ProducerRecord record = new ProducerRecord<>(aggProperties.getTopic(), aggTaskKey, taskValue); kafkaProducer.send(record); - StatUtils.KAFKA_SEND.add(StringsKey.of("v1"), Stats.V_1); + StatUtils.KAFKA_SEND.add(StringsKey.of("v1"), + new long[] {1, taskValue.getInDataNodesCount()}); } } } @@ -291,9 +293,14 @@ public void dispatchDetailData(AuthInfo authInfo, GatewayHook.Table table) { ProducerRecord record = new ProducerRecord<>(aggProperties.getTopic(), aggTaskKey, aggTaskValue); kafkaProducer.send(record); + StatUtils.KAFKA_SEND.add(StringsKey.of("detail"), new long[] {1, table.getRows().size()}); } } + public boolean supportsDetail(String name) { + return CollectionUtils.isNotEmpty(this.storage.getByMetric(name)); + } + @NotNull private static String buildPartition(StringBuilder sb, AuthInfo authInfo, AggTask aggTask) { if (sb == null) { diff --git a/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggGatewayHook.java b/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggGatewayHook.java index 2c78942b4..b2977056d 100644 --- a/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggGatewayHook.java +++ b/server/agg/agg-dispatcher/src/main/java/io/holoinsight/server/agg/v1/dispatcher/AggGatewayHook.java @@ -34,4 +34,9 @@ public void writeMetricsV4(AuthInfo authInfo, WriteMetricsRequestV4 request) { public void writeDetail(AuthInfo authInfo, Table table) { aggDispatcher.dispatchDetailData(authInfo, table); } + + @Override + public boolean supportsDetail(String name) { + return aggDispatcher.supportsDetail(name); + } } diff --git a/server/agg/agg-executor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/XSelect.java b/server/agg/agg-executor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/XSelect.java index 8b9aef1bd..1e480242c 100644 --- a/server/agg/agg-executor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/XSelect.java +++ b/server/agg/agg-executor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/XSelect.java @@ -59,7 +59,8 @@ public Map> getSelectItem(String metric) { XSelectItem item = items.get(index); SelectItem.Elect e = item.getInner().getElect(); - if (item.getInner().getAgg().getTypeInt() == AggFunc.TYPE_HLL) { + int aggType = item.getInner().getAgg().getTypeInt(); + if (aggType == AggFunc.TYPE_HLL || aggType == AggFunc.TYPE_COUNT) { electToItemMap.computeIfAbsent(e.getMetric(), i -> new HashMap<>()) .computeIfAbsent(NO_FIELD, i -> new LinkedList<>()) // .add(item); diff --git a/server/gateway/gateway-core/src/main/java/io/holoinsight/server/gateway/core/grpc/GatewayHook.java b/server/gateway/gateway-core/src/main/java/io/holoinsight/server/gateway/core/grpc/GatewayHook.java index 998b36190..cecec2596 100644 --- a/server/gateway/gateway-core/src/main/java/io/holoinsight/server/gateway/core/grpc/GatewayHook.java +++ b/server/gateway/gateway-core/src/main/java/io/holoinsight/server/gateway/core/grpc/GatewayHook.java @@ -4,7 +4,6 @@ package io.holoinsight.server.gateway.core.grpc; import java.util.List; -import java.util.Map; import io.holoinsight.server.common.auth.AuthInfo; import io.holoinsight.server.gateway.grpc.WriteMetricsRequestV1; @@ -35,6 +34,8 @@ public interface GatewayHook { void writeDetail(AuthInfo authInfo, Table table); + boolean supportsDetail(String name); + @lombok.Data class Table { private String name; @@ -47,6 +48,13 @@ class Table { class Header { private List tagKeys; private List fieldKeys; + + public Header() {} + + public Header(List tagKeys, List fieldKeys) { + this.tagKeys = tagKeys; + this.fieldKeys = fieldKeys; + } } @lombok.Data