From aacbdd5fdf206e1297a4c7c68d0275879ca09119 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sat, 20 Nov 2021 19:51:07 +0800 Subject: [PATCH] =?UTF-8?q?[monitor]=20=E6=8C=87=E6=A0=87=E7=BB=84?= =?UTF-8?q?=E9=87=87=E9=9B=86=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E7=94=B1?= =?UTF-8?q?string=E6=94=B9=E4=B8=BAbyte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collector/dispatch/MetricsCollect.java | 2 +- .../com/usthe/common/entity/job/Configmap.java | 2 +- .../com/usthe/common/entity/job/Metrics.java | 4 ++-- .../com/usthe/common/util/CommonConstants.java | 17 ++++++++++++++++- .../main/resources/define/app/A-example.yml | 18 +++++++++--------- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/collector/server/src/main/java/com/usthe/collector/dispatch/MetricsCollect.java b/collector/server/src/main/java/com/usthe/collector/dispatch/MetricsCollect.java index 518a8eb..dcc94c7 100644 --- a/collector/server/src/main/java/com/usthe/collector/dispatch/MetricsCollect.java +++ b/collector/server/src/main/java/com/usthe/collector/dispatch/MetricsCollect.java @@ -181,7 +181,7 @@ public class MetricsCollect implements Runnable, Comparable { String value = null; if (expression != null) { // 存在计算表达式 则计算值 - if ("number".equals(field.getType())) { + if (CommonConstants.TYPE_NUMBER == field.getType()) { for (String variable : expression.getVariableNames()) { Double doubleValue = CommonUtil.parseDoubleStr(aliasFieldValueMap.get(variable)); if (doubleValue != null) { diff --git a/common/src/main/java/com/usthe/common/entity/job/Configmap.java b/common/src/main/java/com/usthe/common/entity/job/Configmap.java index 388ad51..cc149d0 100644 --- a/common/src/main/java/com/usthe/common/entity/job/Configmap.java +++ b/common/src/main/java/com/usthe/common/entity/job/Configmap.java @@ -32,5 +32,5 @@ public class Configmap { * number,string,secret * 数字,非加密字符串,加密字符串 */ - private byte type; + private byte type = 1; } diff --git a/common/src/main/java/com/usthe/common/entity/job/Metrics.java b/common/src/main/java/com/usthe/common/entity/job/Metrics.java index 8b0542f..751e975 100644 --- a/common/src/main/java/com/usthe/common/entity/job/Metrics.java +++ b/common/src/main/java/com/usthe/common/entity/job/Metrics.java @@ -95,9 +95,9 @@ public class Metrics { */ private String field; /** - * 指标类型 number:数字 string:字符串 + * 指标类型 0-number:数字 1-string:字符串 */ - private String type; + private byte type = 1; /** * 此字段是否为实例主键 */ diff --git a/common/src/main/java/com/usthe/common/util/CommonConstants.java b/common/src/main/java/com/usthe/common/util/CommonConstants.java index bcbb043..92b7337 100644 --- a/common/src/main/java/com/usthe/common/util/CommonConstants.java +++ b/common/src/main/java/com/usthe/common/util/CommonConstants.java @@ -59,7 +59,22 @@ public interface CommonConstants { /** - * null空值占位符 + * 字段参数类型: 数字 + */ + byte TYPE_NUMBER = 0; + + /** + * 字段参数类型: 字符串 + */ + byte TYPE_STRING = 1; + + /** + * 字段参数类型: 加密字符串 + */ + byte TYPE_SECRET = 2; + + /** + * 采集指标值:null空值占位符 */ String NULL_VALUE = " "; } diff --git a/manager/src/main/resources/define/app/A-example.yml b/manager/src/main/resources/define/app/A-example.yml index 87f16d6..5245a15 100644 --- a/manager/src/main/resources/define/app/A-example.yml +++ b/manager/src/main/resources/define/app/A-example.yml @@ -20,17 +20,17 @@ metrics: priority: 0 # 指标组中的具体监控指标 fields: - # 指标信息 包括 field名称, type字段类型:number数字,string字符串,instance是否为实例主键 unit:指标单位 + # 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位 - field: hostname - type: instance + type: 1 instance: true - field: usage - type: number + type: 0 unit: '%' - field: cores - type: number + type: 0 - field: waitTime - type: number + type: 0 unit: s # (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换 aliasFields: @@ -82,16 +82,16 @@ metrics: priority: 1 fields: - field: hostname - type: string + type: 1 instance: true - field: total - type: number + type: 0 unit: kb - field: usage - type: number + type: 0 unit: '%' - field: speed - type: number + type: 0 protocol: http http: host: ^_^host^_^