[alerter] 告警处理指标数据,告警表达式计算,内容模版关键字替换

This commit is contained in:
tomsun28
2021-12-10 12:54:42 +08:00
parent 29b3e23d02
commit 370224f5cf
23 changed files with 693 additions and 44 deletions

View File

@@ -0,0 +1,44 @@
package com.usthe.alert;
import com.usthe.alert.pojo.entity.Alert;
import com.usthe.common.entity.message.CollectRep;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
/**
* 采集数据队列
* @author tom
* @date 2021/11/24 17:58
*/
@Component
@Slf4j
public class AlerterDataQueue {
private final LinkedBlockingQueue<CollectRep.MetricsData> metricsDataQueue;
private final LinkedBlockingQueue<Alert> alertDataQueue;
public AlerterDataQueue() {
metricsDataQueue = new LinkedBlockingQueue<>();
alertDataQueue = new LinkedBlockingQueue<>();
}
public void addMetricsData(CollectRep.MetricsData metricsData) {
metricsDataQueue.offer(metricsData);
}
public CollectRep.MetricsData pollMetricsData() throws InterruptedException {
return metricsDataQueue.poll(2, TimeUnit.SECONDS);
}
public void addAlertData(Alert alert) {
alertDataQueue.offer(alert);
}
public Alert pollAlertData() throws InterruptedException {
return alertDataQueue.poll(2, TimeUnit.SECONDS);
}
}