use of com.usthe.common.entity.job.Metrics in project hertzbeat by dromara.
the class WheelTimerTask method initJobMetrics.
/**
* Initialize job fill information
* 初始化job填充信息
*
* @param job job
*/
private void initJobMetrics(Job job) {
// 将监控实际参数值对采集字段进行替换
List<Configmap> config = job.getConfigmap();
Map<String, Configmap> configmap = config.stream().peek(item -> {
// 对加密串进行解密
if (item.getType() == CommonConstants.PARAM_TYPE_PASSWORD && item.getValue() != null) {
String decodeValue = AesUtil.aesDecode(String.valueOf(item.getValue()));
if (decodeValue == null) {
log.error("Aes Decode value {} error.", item.getValue());
}
item.setValue(decodeValue);
} else if (item.getValue() != null && item.getValue() instanceof String) {
item.setValue(((String) item.getValue()).trim());
}
}).collect(Collectors.toMap(Configmap::getKey, item -> item));
List<Metrics> metrics = job.getMetrics();
List<Metrics> metricsTmp = new ArrayList<>(metrics.size());
for (Metrics metric : metrics) {
JsonElement jsonElement = GSON.toJsonTree(metric);
jsonElement = replaceSpecialValue(jsonElement, configmap);
metric = GSON.fromJson(jsonElement, Metrics.class);
metricsTmp.add(metric);
}
job.setMetrics(metricsTmp);
}
Aggregations