[monitor] 指标组采集字段类型由string改为byte

This commit is contained in:
tomsun28
2021-11-20 19:51:07 +08:00
parent 22f54dff10
commit aacbdd5fdf
5 changed files with 29 additions and 14 deletions

View File

@@ -181,7 +181,7 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
String value = null; String value = null;
if (expression != null) { if (expression != null) {
// 存在计算表达式 则计算值 // 存在计算表达式 则计算值
if ("number".equals(field.getType())) { if (CommonConstants.TYPE_NUMBER == field.getType()) {
for (String variable : expression.getVariableNames()) { for (String variable : expression.getVariableNames()) {
Double doubleValue = CommonUtil.parseDoubleStr(aliasFieldValueMap.get(variable)); Double doubleValue = CommonUtil.parseDoubleStr(aliasFieldValueMap.get(variable));
if (doubleValue != null) { if (doubleValue != null) {

View File

@@ -32,5 +32,5 @@ public class Configmap {
* number,string,secret * number,string,secret
* 数字,非加密字符串,加密字符串 * 数字,非加密字符串,加密字符串
*/ */
private byte type; private byte type = 1;
} }

View File

@@ -95,9 +95,9 @@ public class Metrics {
*/ */
private String field; private String field;
/** /**
* 指标类型 number:数字 string:字符串 * 指标类型 0-number:数字 1-string:字符串
*/ */
private String type; private byte type = 1;
/** /**
* 此字段是否为实例主键 * 此字段是否为实例主键
*/ */

View File

@@ -59,7 +59,22 @@ public interface CommonConstants {
/** /**
* null空值占位符 * 字段参数类型: 数字
*/
byte TYPE_NUMBER = 0;
/**
* 字段参数类型: 字符串
*/
byte TYPE_STRING = 1;
/**
* 字段参数类型: 加密字符串
*/
byte TYPE_SECRET = 2;
/**
* 采集指标值null空值占位符
*/ */
String NULL_VALUE = "&nbsp;"; String NULL_VALUE = "&nbsp;";
} }

View File

@@ -20,17 +20,17 @@ metrics:
priority: 0 priority: 0
# 指标组中的具体监控指标 # 指标组中的具体监控指标
fields: fields:
# 指标信息 包括 field名称, type字段类型:number数字,string字符串,instance是否为实例主键 unit:指标单位 # 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: hostname - field: hostname
type: instance type: 1
instance: true instance: true
- field: usage - field: usage
type: number type: 0
unit: '%' unit: '%'
- field: cores - field: cores
type: number type: 0
- field: waitTime - field: waitTime
type: number type: 0
unit: s unit: s
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换 # (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
aliasFields: aliasFields:
@@ -82,16 +82,16 @@ metrics:
priority: 1 priority: 1
fields: fields:
- field: hostname - field: hostname
type: string type: 1
instance: true instance: true
- field: total - field: total
type: number type: 0
unit: kb unit: kb
- field: usage - field: usage
type: number type: 0
unit: '%' unit: '%'
- field: speed - field: speed
type: number type: 0
protocol: http protocol: http
http: http:
host: ^_^host^_^ host: ^_^host^_^