mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-17 13:52:15 +08:00
kafka-manager 2.0
This commit is contained in:
56
kafka-manager-extends/kafka-manager-monitor/pom.xml
Normal file
56
kafka-manager-extends/kafka-manager-monitor/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-monitor</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>kafka-manager</artifactId>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-dao</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorRuleDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorSilenceDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorAlertDetail;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorRuleSummary;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Alert;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.NotifyGroup;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Silence;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
public interface MonitorService {
|
||||
ResultStatus createMonitorRule(MonitorRuleDTO monitorDTO, String operator);
|
||||
|
||||
ResultStatus deleteMonitorRule(Long id, String operator);
|
||||
|
||||
ResultStatus modifyMonitorRule(MonitorRuleDTO monitorDTO, String operator);
|
||||
|
||||
List<MonitorRuleSummary> getMonitorRules(String operator);
|
||||
|
||||
Result<MonitorRuleDTO> getMonitorRuleDetail(MonitorRuleDO monitorRuleDO);
|
||||
|
||||
MonitorRuleDO getById(Long id);
|
||||
|
||||
MonitorRuleDO getByStrategyId(Long strategyId);
|
||||
|
||||
Result<List<Alert>> getMonitorAlertHistory(Long id, Long startTime, Long endTime);
|
||||
|
||||
Result<MonitorAlertDetail> getMonitorAlertDetail(Long alertId);
|
||||
|
||||
Result createSilence(MonitorSilenceDTO monitorSilenceDTO, String operator);
|
||||
|
||||
Boolean releaseSilence(Long silenceId);
|
||||
|
||||
Result modifySilence(MonitorSilenceDTO monitorSilenceDTO, String operator);
|
||||
|
||||
Result<List<Silence>> getSilences(Long strategyId);
|
||||
|
||||
Silence getSilenceById(Long silenceId);
|
||||
|
||||
List<NotifyGroup> getNotifyGroups();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common;
|
||||
|
||||
/**
|
||||
* @author huangjw
|
||||
* @date 17/5/24.
|
||||
*/
|
||||
public class MonitorSinkConstant {
|
||||
public static final String MONITOR_SYSTEM_TAG_DEFAULT_HOST = "kafka-manager-ser01.ys01";
|
||||
|
||||
/**
|
||||
* 指标名前缀
|
||||
*/
|
||||
public static final String METRIC_NAME_PRE_STR = "online-";
|
||||
|
||||
/**
|
||||
* 单次上报大小
|
||||
*/
|
||||
public static final Integer MONITOR_SYSTEM_SINK_THRESHOLD = 2000;
|
||||
|
||||
/**
|
||||
* 上报周期
|
||||
*/
|
||||
public static final Integer MONITOR_SYSTEM_SINK_STEP = 60;
|
||||
|
||||
public static final Integer MONITOR_SYSTEM_METRIC_VALUE_EFFECTIVE = 1;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MetricPoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class Alert {
|
||||
/**
|
||||
* 告警ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控ID
|
||||
*/
|
||||
private Long monitorId;
|
||||
|
||||
/**
|
||||
* 监控策略ID
|
||||
*/
|
||||
private Long strategyId;
|
||||
|
||||
/**
|
||||
* 监控策略名称
|
||||
*/
|
||||
private String strategyName;
|
||||
|
||||
/**
|
||||
* 告警类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 告警优先级
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 告警的指标
|
||||
*/
|
||||
private String metric;
|
||||
|
||||
/**
|
||||
* 触发告警的曲线tags
|
||||
*/
|
||||
private Properties tags;
|
||||
|
||||
/**
|
||||
* 告警开始时间
|
||||
*/
|
||||
private Long startTime;
|
||||
|
||||
/**
|
||||
* 告警结束时间
|
||||
*/
|
||||
private Long endTime;
|
||||
|
||||
/**
|
||||
* 现场值
|
||||
*/
|
||||
private Double value;
|
||||
|
||||
/**
|
||||
* 现场值
|
||||
*/
|
||||
private List<MetricPoint> points;
|
||||
|
||||
/**
|
||||
* 告警组
|
||||
*/
|
||||
private List<String> groups;
|
||||
|
||||
/**
|
||||
* 表达式
|
||||
*/
|
||||
private String info;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getMonitorId() {
|
||||
return monitorId;
|
||||
}
|
||||
|
||||
public void setMonitorId(Long monitorId) {
|
||||
this.monitorId = monitorId;
|
||||
}
|
||||
|
||||
public Long getStrategyId() {
|
||||
return strategyId;
|
||||
}
|
||||
|
||||
public void setStrategyId(Long strategyId) {
|
||||
this.strategyId = strategyId;
|
||||
}
|
||||
|
||||
public String getStrategyName() {
|
||||
return strategyName;
|
||||
}
|
||||
|
||||
public void setStrategyName(String strategyName) {
|
||||
this.strategyName = strategyName;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Properties getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Properties tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public List<MetricPoint> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(List<MetricPoint> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(List<String> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Alert{" +
|
||||
"id=" + id +
|
||||
", monitorId=" + monitorId +
|
||||
", strategyId=" + strategyId +
|
||||
", strategyName='" + strategyName + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", priority=" + priority +
|
||||
", metric='" + metric + '\'' +
|
||||
", tags=" + tags +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", value=" + value +
|
||||
", points=" + points +
|
||||
", groups=" + groups +
|
||||
", info='" + info + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MetricPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/28
|
||||
*/
|
||||
public class Metric {
|
||||
private String metric;
|
||||
|
||||
private Integer step;
|
||||
|
||||
private List<MetricPoint> values;
|
||||
|
||||
private Integer comparison;
|
||||
|
||||
private Integer delta;
|
||||
|
||||
private Boolean origin;
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Integer getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(Integer step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public List<MetricPoint> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<MetricPoint> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public Integer getComparison() {
|
||||
return comparison;
|
||||
}
|
||||
|
||||
public void setComparison(Integer comparison) {
|
||||
this.comparison = comparison;
|
||||
}
|
||||
|
||||
public Integer getDelta() {
|
||||
return delta;
|
||||
}
|
||||
|
||||
public void setDelta(Integer delta) {
|
||||
this.delta = delta;
|
||||
}
|
||||
|
||||
public Boolean getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(Boolean origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Metric{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", step=" + step +
|
||||
", values=" + values +
|
||||
", comparison=" + comparison +
|
||||
", delta=" + delta +
|
||||
", origin=" + origin +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.sink.MonitorBaseSinkTag;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @author huangjw
|
||||
* @date 17/5/24.
|
||||
*/
|
||||
public class MetricSinkPoint {
|
||||
/**
|
||||
* 指标名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 指标值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 上报周期
|
||||
*/
|
||||
private int step;
|
||||
|
||||
/**
|
||||
* 当前时间戳,单位为s
|
||||
*/
|
||||
private long timestamp;
|
||||
|
||||
/**
|
||||
* tags
|
||||
*/
|
||||
private MonitorBaseSinkTag tags;
|
||||
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00");
|
||||
|
||||
public MetricSinkPoint(String name, double value, int step, long timestamp, MonitorBaseSinkTag tags) {
|
||||
if (value <= 0.001) {
|
||||
value = 0.0;
|
||||
}
|
||||
this.name = name;
|
||||
this.value = DECIMAL_FORMAT.format(value);
|
||||
this.step = step;
|
||||
this.timestamp = timestamp;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public MonitorBaseSinkTag getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public int getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetricPoint{" +
|
||||
"name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", timestamp=" + timestamp +
|
||||
", tags=" + tags +
|
||||
", step=" + step +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/27
|
||||
*/
|
||||
public class NotifyGroup {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String comment;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NotifyGroup{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", comment='" + comment + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class Silence {
|
||||
private Long silenceId;
|
||||
|
||||
/**
|
||||
* 屏蔽的策略ID
|
||||
*/
|
||||
private Long strategyId;
|
||||
|
||||
/**
|
||||
* 屏蔽开始时间
|
||||
*/
|
||||
private Long beginTime;
|
||||
|
||||
/**
|
||||
* 屏蔽结束时间
|
||||
*/
|
||||
private Long endTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String description;
|
||||
|
||||
public Long getSilenceId() {
|
||||
return silenceId;
|
||||
}
|
||||
|
||||
public void setSilenceId(Long silenceId) {
|
||||
this.silenceId = silenceId;
|
||||
}
|
||||
|
||||
public Long getStrategyId() {
|
||||
return strategyId;
|
||||
}
|
||||
|
||||
public void setStrategyId(Long strategyId) {
|
||||
this.strategyId = strategyId;
|
||||
}
|
||||
|
||||
public Long getBeginTime() {
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
public void setBeginTime(Long beginTime) {
|
||||
this.beginTime = beginTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Silence{" +
|
||||
"silenceId=" + silenceId +
|
||||
", strategyId=" + strategyId +
|
||||
", beginTime=" + beginTime +
|
||||
", endTime=" + endTime +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/4
|
||||
*/
|
||||
public class Strategy {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer priority;
|
||||
|
||||
private String periodHoursOfDay;
|
||||
|
||||
private String periodDaysOfWeek;
|
||||
|
||||
private List<StrategyExpression> strategyExpressionList;
|
||||
|
||||
private List<StrategyFilter> strategyFilterList;
|
||||
|
||||
private List<StrategyAction> strategyActionList;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getPeriodHoursOfDay() {
|
||||
return periodHoursOfDay;
|
||||
}
|
||||
|
||||
public void setPeriodHoursOfDay(String periodHoursOfDay) {
|
||||
this.periodHoursOfDay = periodHoursOfDay;
|
||||
}
|
||||
|
||||
public String getPeriodDaysOfWeek() {
|
||||
return periodDaysOfWeek;
|
||||
}
|
||||
|
||||
public void setPeriodDaysOfWeek(String periodDaysOfWeek) {
|
||||
this.periodDaysOfWeek = periodDaysOfWeek;
|
||||
}
|
||||
|
||||
public List<StrategyExpression> getStrategyExpressionList() {
|
||||
return strategyExpressionList;
|
||||
}
|
||||
|
||||
public void setStrategyExpressionList(List<StrategyExpression> strategyExpressionList) {
|
||||
this.strategyExpressionList = strategyExpressionList;
|
||||
}
|
||||
|
||||
public List<StrategyFilter> getStrategyFilterList() {
|
||||
return strategyFilterList;
|
||||
}
|
||||
|
||||
public void setStrategyFilterList(List<StrategyFilter> strategyFilterList) {
|
||||
this.strategyFilterList = strategyFilterList;
|
||||
}
|
||||
|
||||
public List<StrategyAction> getStrategyActionList() {
|
||||
return strategyActionList;
|
||||
}
|
||||
|
||||
public void setStrategyActionList(List<StrategyAction> strategyActionList) {
|
||||
this.strategyActionList = strategyActionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Strategy{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", priority=" + priority +
|
||||
", periodHoursOfDay='" + periodHoursOfDay + '\'' +
|
||||
", periodDaysOfWeek='" + periodDaysOfWeek + '\'' +
|
||||
", strategyExpressionList=" + strategyExpressionList +
|
||||
", strategyFilterList=" + strategyFilterList +
|
||||
", strategyActionList=" + strategyActionList +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (name == null
|
||||
|| priority == null
|
||||
|| periodHoursOfDay == null
|
||||
|| periodDaysOfWeek == null
|
||||
|| strategyExpressionList == null || strategyExpressionList.isEmpty()
|
||||
|| strategyFilterList == null || strategyFilterList.isEmpty()
|
||||
|| strategyActionList == null || strategyActionList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (StrategyExpression dto: strategyExpressionList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (StrategyFilter dto: strategyFilterList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (StrategyAction dto: strategyActionList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class StrategyAction {
|
||||
private String notifyGroup;
|
||||
|
||||
private String converge;
|
||||
|
||||
private String callback;
|
||||
|
||||
public String getNotifyGroup() {
|
||||
return notifyGroup;
|
||||
}
|
||||
|
||||
public void setNotifyGroup(String notifyGroup) {
|
||||
this.notifyGroup = notifyGroup;
|
||||
}
|
||||
|
||||
public String getConverge() {
|
||||
return converge;
|
||||
}
|
||||
|
||||
public void setConverge(String converge) {
|
||||
this.converge = converge;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(String callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StrategyAction{" +
|
||||
"notifyGroup=" + notifyGroup +
|
||||
", converge='" + converge + '\'' +
|
||||
", callback='" + callback + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (notifyGroup == null || converge == null) {
|
||||
return false;
|
||||
}
|
||||
callback = (callback == null? "": callback);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class StrategyExpression {
|
||||
private String metric;
|
||||
|
||||
private String func;
|
||||
|
||||
private String eopt;
|
||||
|
||||
private Long threshold;
|
||||
|
||||
private String params;
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public String getFunc() {
|
||||
return func;
|
||||
}
|
||||
|
||||
public void setFunc(String func) {
|
||||
this.func = func;
|
||||
}
|
||||
|
||||
public String getEopt() {
|
||||
return eopt;
|
||||
}
|
||||
|
||||
public void setEopt(String eopt) {
|
||||
this.eopt = eopt;
|
||||
}
|
||||
|
||||
public Long getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public void setThreshold(Long threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StrategyExpression{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", func='" + func + '\'' +
|
||||
", eopt='" + eopt + '\'' +
|
||||
", threshold=" + threshold +
|
||||
", params=" + params +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (metric == null
|
||||
|| func == null
|
||||
|| eopt == null
|
||||
|| threshold == null
|
||||
|| params == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class StrategyFilter {
|
||||
private String tkey;
|
||||
|
||||
private String topt;
|
||||
|
||||
private String tval;
|
||||
|
||||
public String getTkey() {
|
||||
return tkey;
|
||||
}
|
||||
|
||||
public void setTkey(String tkey) {
|
||||
this.tkey = tkey;
|
||||
}
|
||||
|
||||
public String getTopt() {
|
||||
return topt;
|
||||
}
|
||||
|
||||
public void setTopt(String topt) {
|
||||
this.topt = topt;
|
||||
}
|
||||
|
||||
public String getTval() {
|
||||
return tval;
|
||||
}
|
||||
|
||||
public void setTval(String tval) {
|
||||
this.tval = tval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StrategyFilter{" +
|
||||
"tkey='" + tkey + '\'' +
|
||||
", topt='" + topt + '\'' +
|
||||
", tval=" + tval +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (tkey == null
|
||||
|| topt == null
|
||||
|| tval == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.bizenum;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.MonitorSinkConstant;
|
||||
|
||||
/**
|
||||
* 监控指标名
|
||||
* @author zengqiao
|
||||
* @date 20/5/24
|
||||
*/
|
||||
public enum MonitorMetricNameEnum {
|
||||
TOPIC_MSG_IN(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-topic-msgIn", "条"),
|
||||
|
||||
TOPIC_BYTES_IN(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-topic-bytesIn", "字节/秒"),
|
||||
|
||||
TOPIC_BYTES_REJECTED(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-topic-bytesRejected", "字节/秒"),
|
||||
|
||||
TOPIC_APP_PRODUCE_THROTTLE(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-topic-produce-throttled", "1:被限流"),
|
||||
|
||||
TOPIC_APP_FETCH_THROTTLE(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-topic-fetch-throttled", "1:被限流"),
|
||||
|
||||
CONSUMER_MAX_LAG(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-consumer-maxLag", "条"),
|
||||
|
||||
CONSUMER_PARTITION_LAG(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-consumer-lag", "条"),
|
||||
|
||||
CONSUMER_MAX_DELAY_TIME(MonitorSinkConstant.METRIC_NAME_PRE_STR + "kafka-consumer-maxDelayTime", "秒"),
|
||||
|
||||
;
|
||||
|
||||
private String metricName;
|
||||
|
||||
private String unit;
|
||||
|
||||
MonitorMetricNameEnum(String metricName, String unit) {
|
||||
this.metricName = metricName;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public String getMetricName() {
|
||||
return metricName;
|
||||
}
|
||||
|
||||
public void setMetricName(String metricName) {
|
||||
this.metricName = metricName;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorMetricNameEnum{" +
|
||||
"metricName='" + metricName + '\'' +
|
||||
", unit='" + unit + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/22
|
||||
*/
|
||||
public class MetricPoint {
|
||||
private Double value;
|
||||
|
||||
private Long timestamp;
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AlertPoint{" +
|
||||
"value=" + value +
|
||||
", timestamp=" + timestamp +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/4
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description = "监控告警")
|
||||
public class MonitorRuleDTO {
|
||||
@ApiModelProperty(value = "所属AppID")
|
||||
private String appId;
|
||||
|
||||
@ApiModelProperty(value = "ID, 修改时使用")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "报警名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "报警等级,1级:电话+短信+钉钉+邮件,2:短信+钉钉+邮件 3:钉钉+邮件")
|
||||
private Integer priority;
|
||||
|
||||
@ApiModelProperty(value = "报警生效时间,小时,24小时计,以逗号分隔")
|
||||
private String periodHoursOfDay;
|
||||
|
||||
@ApiModelProperty(value = "报警生效时间,星期,7天计")
|
||||
private String periodDaysOfWeek;
|
||||
|
||||
@ApiModelProperty(value = "报警规则")
|
||||
private List<MonitorStrategyExpressionDTO> strategyExpressionList;
|
||||
|
||||
@ApiModelProperty(value = "过滤规则")
|
||||
private List<MonitorStrategyFilterDTO> strategyFilterList;
|
||||
|
||||
@ApiModelProperty(value = "通知方式")
|
||||
private List<MonitorStrategyActionDTO> strategyActionList;
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getPeriodHoursOfDay() {
|
||||
return periodHoursOfDay;
|
||||
}
|
||||
|
||||
public void setPeriodHoursOfDay(String periodHoursOfDay) {
|
||||
this.periodHoursOfDay = periodHoursOfDay;
|
||||
}
|
||||
|
||||
public String getPeriodDaysOfWeek() {
|
||||
return periodDaysOfWeek;
|
||||
}
|
||||
|
||||
public void setPeriodDaysOfWeek(String periodDaysOfWeek) {
|
||||
this.periodDaysOfWeek = periodDaysOfWeek;
|
||||
}
|
||||
|
||||
public List<MonitorStrategyExpressionDTO> getStrategyExpressionList() {
|
||||
return strategyExpressionList;
|
||||
}
|
||||
|
||||
public void setStrategyExpressionList(List<MonitorStrategyExpressionDTO> strategyExpressionList) {
|
||||
this.strategyExpressionList = strategyExpressionList;
|
||||
}
|
||||
|
||||
public List<MonitorStrategyFilterDTO> getStrategyFilterList() {
|
||||
return strategyFilterList;
|
||||
}
|
||||
|
||||
public void setStrategyFilterList(List<MonitorStrategyFilterDTO> strategyFilterList) {
|
||||
this.strategyFilterList = strategyFilterList;
|
||||
}
|
||||
|
||||
public List<MonitorStrategyActionDTO> getStrategyActionList() {
|
||||
return strategyActionList;
|
||||
}
|
||||
|
||||
public void setStrategyActionList(List<MonitorStrategyActionDTO> strategyActionList) {
|
||||
this.strategyActionList = strategyActionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorRuleDTO{" +
|
||||
"appId='" + appId + '\'' +
|
||||
", id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", priority=" + priority +
|
||||
", periodHoursOfDay='" + periodHoursOfDay + '\'' +
|
||||
", periodDaysOfWeek='" + periodDaysOfWeek + '\'' +
|
||||
", strategyExpressionList=" + strategyExpressionList +
|
||||
", strategyFilterList=" + strategyFilterList +
|
||||
", strategyActionList=" + strategyActionList +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isBlank(appId)
|
||||
|| ValidateUtils.isBlank(name)
|
||||
|| ValidateUtils.isNull(priority)
|
||||
|| ValidateUtils.isBlank(periodHoursOfDay)
|
||||
|| ValidateUtils.isBlank(periodDaysOfWeek)
|
||||
|| ValidateUtils.isEmptyList(strategyExpressionList)
|
||||
|| ValidateUtils.isNull(strategyFilterList)
|
||||
|| ValidateUtils.isEmptyList(strategyActionList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MonitorStrategyExpressionDTO dto: strategyExpressionList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (MonitorStrategyFilterDTO dto: strategyFilterList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (MonitorStrategyActionDTO dto: strategyActionList) {
|
||||
if (!dto.paramLegal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description = "监控告警")
|
||||
public class MonitorSilenceDTO {
|
||||
@ApiModelProperty(value = "ID, 修改时传")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "告警ID")
|
||||
private Long monitorId;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Long endTime;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String description;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getMonitorId() {
|
||||
return monitorId;
|
||||
}
|
||||
|
||||
public void setMonitorId(Long monitorId) {
|
||||
this.monitorId = monitorId;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorSilenceDTO{" +
|
||||
"id=" + id +
|
||||
", monitorId=" + monitorId +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isNull(monitorId)
|
||||
|| ValidateUtils.isNull(startTime)
|
||||
|| ValidateUtils.isNull(endTime)
|
||||
|| ValidateUtils.isNull(description)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description = "通知方式")
|
||||
public class MonitorStrategyActionDTO {
|
||||
@ApiModelProperty(value = "报警组")
|
||||
private List<String> notifyGroup;
|
||||
|
||||
@ApiModelProperty(value = "连续报警时间")
|
||||
private String converge;
|
||||
|
||||
@ApiModelProperty(value = "回调地址")
|
||||
private String callback;
|
||||
|
||||
public List<String> getNotifyGroup() {
|
||||
return notifyGroup;
|
||||
}
|
||||
|
||||
public void setNotifyGroup(List<String> notifyGroup) {
|
||||
this.notifyGroup = notifyGroup;
|
||||
}
|
||||
|
||||
public String getConverge() {
|
||||
return converge;
|
||||
}
|
||||
|
||||
public void setConverge(String converge) {
|
||||
this.converge = converge;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(String callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorStrategyActionDTO{" +
|
||||
"notifyGroup=" + notifyGroup +
|
||||
", converge='" + converge + '\'' +
|
||||
", callback='" + callback + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isEmptyList(notifyGroup)
|
||||
|| ValidateUtils.isBlank(converge)) {
|
||||
return false;
|
||||
}
|
||||
callback = ValidateUtils.isNull(callback)? "": callback;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/4
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description = "报警规则")
|
||||
public class MonitorStrategyExpressionDTO {
|
||||
@ApiModelProperty(value = "指标名")
|
||||
private String metric;
|
||||
|
||||
@ApiModelProperty(value = "计算规则")
|
||||
private String func;
|
||||
|
||||
@ApiModelProperty(value = "操作符")
|
||||
private String eopt;
|
||||
|
||||
@ApiModelProperty(value = "阈值")
|
||||
private Long threshold;
|
||||
|
||||
@ApiModelProperty(value = "参数见规则描述")
|
||||
private String params;
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public String getFunc() {
|
||||
return func;
|
||||
}
|
||||
|
||||
public void setFunc(String func) {
|
||||
this.func = func;
|
||||
}
|
||||
|
||||
public String getEopt() {
|
||||
return eopt;
|
||||
}
|
||||
|
||||
public void setEopt(String eopt) {
|
||||
this.eopt = eopt;
|
||||
}
|
||||
|
||||
public Long getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public void setThreshold(Long threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorStrategyExpressionDTO{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", func='" + func + '\'' +
|
||||
", eopt='" + eopt + '\'' +
|
||||
", threshold=" + threshold +
|
||||
", params=" + params +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isBlank(metric)
|
||||
|| ValidateUtils.isBlank(func)
|
||||
|| ValidateUtils.isBlank(eopt)
|
||||
|| ValidateUtils.isNull(threshold)
|
||||
|| ValidateUtils.isBlank(params)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description = "指标过滤规则")
|
||||
public class MonitorStrategyFilterDTO {
|
||||
@ApiModelProperty(value = "指标")
|
||||
private String tkey;
|
||||
|
||||
@ApiModelProperty(value = "条件")
|
||||
private String topt;
|
||||
|
||||
@ApiModelProperty(value = "值")
|
||||
private List<String> tval;
|
||||
|
||||
public String getTkey() {
|
||||
return tkey;
|
||||
}
|
||||
|
||||
public void setTkey(String tkey) {
|
||||
this.tkey = tkey;
|
||||
}
|
||||
|
||||
public String getTopt() {
|
||||
return topt;
|
||||
}
|
||||
|
||||
public void setTopt(String topt) {
|
||||
this.topt = topt;
|
||||
}
|
||||
|
||||
public List<String> getTval() {
|
||||
return tval;
|
||||
}
|
||||
|
||||
public void setTval(List<String> tval) {
|
||||
this.tval = tval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorStrategyFilterDTO{" +
|
||||
"tkey='" + tkey + '\'' +
|
||||
", topt='" + topt + '\'' +
|
||||
", tval=" + tval +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isBlank(tkey)
|
||||
|| ValidateUtils.isBlank(topt)
|
||||
|| ValidateUtils.isEmptyList(tval)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/24
|
||||
*/
|
||||
public class MonitorBaseSinkTag {
|
||||
/**
|
||||
* 主机名
|
||||
*/
|
||||
protected String host;
|
||||
|
||||
public MonitorBaseSinkTag(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseTag{" +
|
||||
"host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/09/02
|
||||
*/
|
||||
public class MonitorConsumePartitionSinkTag extends MonitorTopicPartitionSinkTag {
|
||||
private String consumerGroup;
|
||||
|
||||
public MonitorConsumePartitionSinkTag(String host, String cluster, String topic, Integer partition, String consumerGroup) {
|
||||
super(host, cluster, topic, partition);
|
||||
this.consumerGroup = consumerGroup;
|
||||
}
|
||||
|
||||
public String getConsumerGroup() {
|
||||
return consumerGroup;
|
||||
}
|
||||
|
||||
public void setConsumerGroup(String consumerGroup) {
|
||||
this.consumerGroup = consumerGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorConsumePartitionSinkTag{" +
|
||||
"consumerGroup='" + consumerGroup + '\'' +
|
||||
", topic='" + topic + '\'' +
|
||||
", partition='" + partition + '\'' +
|
||||
", cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author huangjw
|
||||
* @date 17/5/25.
|
||||
*/
|
||||
public class MonitorConsumerSinkTag extends MonitorKafkaBaseSinkTag {
|
||||
private String topic;
|
||||
|
||||
private String consumerGroup;
|
||||
|
||||
public MonitorConsumerSinkTag(String host, String cluster, String topic, String consumerGroup) {
|
||||
super(host, cluster);
|
||||
this.topic = topic;
|
||||
this.consumerGroup = consumerGroup;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public String getConsumerGroup() {
|
||||
return consumerGroup;
|
||||
}
|
||||
|
||||
public void setConsumerGroup(String consumerGroup) {
|
||||
this.consumerGroup = consumerGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorConsumerSinkTag{" +
|
||||
"topic='" + topic + '\'' +
|
||||
", consumerGroup='" + consumerGroup + '\'' +
|
||||
", cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/24
|
||||
*/
|
||||
public class MonitorKafkaBaseSinkTag extends MonitorBaseSinkTag {
|
||||
protected String cluster;
|
||||
|
||||
public MonitorKafkaBaseSinkTag(String host, String cluster) {
|
||||
super(host);
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
public String getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public void setCluster(String cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorKafkaBaseSinkTag{" +
|
||||
"cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/3
|
||||
*/
|
||||
public class MonitorTopicPartitionSinkTag extends MonitorKafkaBaseSinkTag {
|
||||
protected String topic;
|
||||
|
||||
protected String partition;
|
||||
|
||||
public MonitorTopicPartitionSinkTag(String host, String cluster, String topic, Integer partition) {
|
||||
super(host, cluster);
|
||||
this.topic = topic;
|
||||
this.partition = String.valueOf(partition);
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public String getPartition() {
|
||||
return partition;
|
||||
}
|
||||
|
||||
public void setPartition(String partition) {
|
||||
this.partition = partition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorTopicPartitionSinkTag{" +
|
||||
"topic='" + topic + '\'' +
|
||||
", partition='" + partition + '\'' +
|
||||
", cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author huangjw
|
||||
* @date 17/5/24.
|
||||
*/
|
||||
public class MonitorTopicSinkTag extends MonitorKafkaBaseSinkTag {
|
||||
|
||||
private String topic;
|
||||
|
||||
public MonitorTopicSinkTag(String host, String cluster, String topic) {
|
||||
super(host, cluster);
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorTopicSinkTag{" +
|
||||
"topic='" + topic + '\'' +
|
||||
", cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.sink;
|
||||
|
||||
/**
|
||||
* @author crius
|
||||
* @date 19/5/21.
|
||||
*/
|
||||
public class MonitorTopicThrottledSinkTag extends MonitorKafkaBaseSinkTag {
|
||||
private String topic;
|
||||
|
||||
private String appId;
|
||||
|
||||
public MonitorTopicThrottledSinkTag(String host, String cluster, String topic, String appId) {
|
||||
super(host, cluster);
|
||||
this.topic = topic;
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorTopicThrottledSinkTag{" +
|
||||
"topic='" + topic + '\'' +
|
||||
", appId='" + appId + '\'' +
|
||||
", cluster='" + cluster + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
@ApiModel(description = "告警详情")
|
||||
public class MonitorAlertDetailVO {
|
||||
private MonitorAlertVO monitorAlert;
|
||||
|
||||
private MonitorMetricVO monitorMetric;
|
||||
|
||||
public MonitorAlertVO getMonitorAlert() {
|
||||
return monitorAlert;
|
||||
}
|
||||
|
||||
public void setMonitorAlert(MonitorAlertVO monitorAlert) {
|
||||
this.monitorAlert = monitorAlert;
|
||||
}
|
||||
|
||||
public MonitorMetricVO getMonitorMetric() {
|
||||
return monitorMetric;
|
||||
}
|
||||
|
||||
public void setMonitorMetric(MonitorMetricVO monitorMetric) {
|
||||
this.monitorMetric = monitorMetric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorAlertDetailVO{" +
|
||||
"monitorAlert=" + monitorAlert +
|
||||
", monitorMetric=" + monitorMetric +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MetricPoint;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@ApiModel(description = "告警信息")
|
||||
public class MonitorAlertVO {
|
||||
@ApiModelProperty(value = "告警ID")
|
||||
private Long alertId;
|
||||
|
||||
@ApiModelProperty(value = "监控ID")
|
||||
private Long monitorId;
|
||||
|
||||
@ApiModelProperty(value = "监控名称")
|
||||
private String monitorName;
|
||||
|
||||
@ApiModelProperty(value = "监控级别")
|
||||
private Integer monitorPriority;
|
||||
|
||||
@ApiModelProperty(value = "告警状态")
|
||||
private Integer alertStatus;
|
||||
|
||||
@ApiModelProperty(value = "告警开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "告警结束时间")
|
||||
private Long endTime;
|
||||
|
||||
@ApiModelProperty(value = "告警的指标")
|
||||
private String metric;
|
||||
|
||||
@ApiModelProperty(value = "触发值")
|
||||
private Double value;
|
||||
|
||||
@ApiModelProperty(value = "现场值")
|
||||
private List<MetricPoint> points;
|
||||
|
||||
@ApiModelProperty(value = "告警组")
|
||||
private List<String> groups;
|
||||
|
||||
@ApiModelProperty(value = "表达式")
|
||||
private String info;
|
||||
|
||||
public Long getAlertId() {
|
||||
return alertId;
|
||||
}
|
||||
|
||||
public void setAlertId(Long alertId) {
|
||||
this.alertId = alertId;
|
||||
}
|
||||
|
||||
public Long getMonitorId() {
|
||||
return monitorId;
|
||||
}
|
||||
|
||||
public void setMonitorId(Long monitorId) {
|
||||
this.monitorId = monitorId;
|
||||
}
|
||||
|
||||
public String getMonitorName() {
|
||||
return monitorName;
|
||||
}
|
||||
|
||||
public void setMonitorName(String monitorName) {
|
||||
this.monitorName = monitorName;
|
||||
}
|
||||
|
||||
public Integer getMonitorPriority() {
|
||||
return monitorPriority;
|
||||
}
|
||||
|
||||
public void setMonitorPriority(Integer monitorPriority) {
|
||||
this.monitorPriority = monitorPriority;
|
||||
}
|
||||
|
||||
public Integer getAlertStatus() {
|
||||
return alertStatus;
|
||||
}
|
||||
|
||||
public void setAlertStatus(Integer alertStatus) {
|
||||
this.alertStatus = alertStatus;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public List<MetricPoint> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(List<MetricPoint> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(List<String> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorAlertVO{" +
|
||||
"alertId=" + alertId +
|
||||
", monitorId=" + monitorId +
|
||||
", monitorName='" + monitorName + '\'' +
|
||||
", monitorPriority=" + monitorPriority +
|
||||
", alertStatus=" + alertStatus +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", metric='" + metric + '\'' +
|
||||
", value=" + value +
|
||||
", points=" + points +
|
||||
", groups=" + groups +
|
||||
", info='" + info + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/28
|
||||
*/
|
||||
public class MonitorMetricPoint {
|
||||
private Long timestamp;
|
||||
|
||||
private Double value;
|
||||
|
||||
public MonitorMetricPoint(Long timestamp, Double value) {
|
||||
this.timestamp = timestamp;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorMetricPoint{" +
|
||||
"value=" + value +
|
||||
", timestamp=" + timestamp +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/28
|
||||
*/
|
||||
public class MonitorMetricVO {
|
||||
private String metric;
|
||||
|
||||
private Integer step;
|
||||
|
||||
private List<MonitorMetricPoint> values;
|
||||
|
||||
private Integer comparison;
|
||||
|
||||
private Integer delta;
|
||||
|
||||
private Boolean origin;
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Integer getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(Integer step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public List<MonitorMetricPoint> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<MonitorMetricPoint> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public Integer getComparison() {
|
||||
return comparison;
|
||||
}
|
||||
|
||||
public void setComparison(Integer comparison) {
|
||||
this.comparison = comparison;
|
||||
}
|
||||
|
||||
public Integer getDelta() {
|
||||
return delta;
|
||||
}
|
||||
|
||||
public void setDelta(Integer delta) {
|
||||
this.delta = delta;
|
||||
}
|
||||
|
||||
public Boolean getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(Boolean origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorMetricVO{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", step=" + step +
|
||||
", values=" + values +
|
||||
", comparison=" + comparison +
|
||||
", delta=" + delta +
|
||||
", origin=" + origin +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/27
|
||||
*/
|
||||
@ApiModel(description = "告警屏蔽")
|
||||
public class MonitorNotifyGroupVO {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String comment;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorNotifyGroupVO{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", comment='" + comment + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorRuleDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.app.AppSummaryVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@ApiModel(description = "告警规则详情")
|
||||
public class MonitorRuleDetailVO {
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String operator;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Long modifyTime;
|
||||
|
||||
@ApiModelProperty(value = "App概览")
|
||||
private AppSummaryVO appSummary;
|
||||
|
||||
@ApiModelProperty(value = "App概览")
|
||||
private MonitorRuleDTO monitorRule;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Long modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public AppSummaryVO getAppSummary() {
|
||||
return appSummary;
|
||||
}
|
||||
|
||||
public void setAppSummary(AppSummaryVO appSummary) {
|
||||
this.appSummary = appSummary;
|
||||
}
|
||||
|
||||
public MonitorRuleDTO getMonitorRule() {
|
||||
return monitorRule;
|
||||
}
|
||||
|
||||
public void setMonitorRule(MonitorRuleDTO monitorRule) {
|
||||
this.monitorRule = monitorRule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorRuleDetailVO{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", operator='" + operator + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", modifyTime=" + modifyTime +
|
||||
", appSummary=" + appSummary +
|
||||
", monitorRule=" + monitorRule +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@ApiModel(description = "监控告警")
|
||||
public class MonitorRuleSummaryVO {
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "告警名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "应用ID")
|
||||
private String appId;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "应用负责任")
|
||||
private String principals;
|
||||
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private String operator;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getPrincipals() {
|
||||
return principals;
|
||||
}
|
||||
|
||||
public void setPrincipals(String principals) {
|
||||
this.principals = principals;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorRuleSummaryVO{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", appId='" + appId + '\'' +
|
||||
", appName='" + appName + '\'' +
|
||||
", principals='" + principals + '\'' +
|
||||
", operator='" + operator + '\'' +
|
||||
", createTime=" + createTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/18
|
||||
*/
|
||||
@ApiModel(description = "告警屏蔽")
|
||||
public class MonitorSilenceVO {
|
||||
@ApiModelProperty(value = "屏蔽ID")
|
||||
private Long silenceId;
|
||||
|
||||
@ApiModelProperty(value = "告警ID")
|
||||
private Long monitorId;
|
||||
|
||||
@ApiModelProperty(value = "监控名称")
|
||||
private String monitorName;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Long endTime;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String description;
|
||||
|
||||
public Long getSilenceId() {
|
||||
return silenceId;
|
||||
}
|
||||
|
||||
public void setSilenceId(Long silenceId) {
|
||||
this.silenceId = silenceId;
|
||||
}
|
||||
|
||||
public Long getMonitorId() {
|
||||
return monitorId;
|
||||
}
|
||||
|
||||
public void setMonitorId(Long monitorId) {
|
||||
this.monitorId = monitorId;
|
||||
}
|
||||
|
||||
public String getMonitorName() {
|
||||
return monitorName;
|
||||
}
|
||||
|
||||
public void setMonitorName(String monitorName) {
|
||||
this.monitorName = monitorName;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorSilenceVO{" +
|
||||
"silenceId=" + silenceId +
|
||||
", monitorId=" + monitorId +
|
||||
", monitorName='" + monitorName + '\'' +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.monitor;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Alert;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Metric;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/22
|
||||
*/
|
||||
public class MonitorAlertDetail {
|
||||
private Alert alert;
|
||||
|
||||
private Metric metric;
|
||||
|
||||
public MonitorAlertDetail(Alert alert, Metric metric) {
|
||||
this.alert = alert;
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Alert getAlert() {
|
||||
return alert;
|
||||
}
|
||||
|
||||
public void setAlert(Alert alert) {
|
||||
this.alert = alert;
|
||||
}
|
||||
|
||||
public Metric getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(Metric metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorAlertDetail{" +
|
||||
"alert=" + alert +
|
||||
", metric=" + metric +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.monitor;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/22
|
||||
*/
|
||||
public class MonitorRuleSummary {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String appId;
|
||||
|
||||
private String appName;
|
||||
|
||||
private String principals;
|
||||
|
||||
private String operator;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getPrincipals() {
|
||||
return principals;
|
||||
}
|
||||
|
||||
public void setPrincipals(String principals) {
|
||||
this.principals = principals;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MonitorRuleSummary{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", appId='" + appId + '\'' +
|
||||
", appName='" + appName + '\'' +
|
||||
", principals='" + principals + '\'' +
|
||||
", operator='" + operator + '\'' +
|
||||
", createTime=" + createTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.utils;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.*;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.*;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
public class CommonConverter {
|
||||
public static Strategy convert2Strategy(Long strategyId, MonitorRuleDTO monitorDTO) {
|
||||
Strategy strategy = new Strategy();
|
||||
|
||||
strategy.setId(strategyId);
|
||||
strategy.setName(monitorDTO.getName());
|
||||
strategy.setPriority(monitorDTO.getPriority());
|
||||
strategy.setPeriodHoursOfDay(monitorDTO.getPeriodHoursOfDay());
|
||||
strategy.setPeriodDaysOfWeek(monitorDTO.getPeriodDaysOfWeek());
|
||||
strategy.setStrategyExpressionList(new ArrayList<>());
|
||||
strategy.setStrategyFilterList(new ArrayList<>());
|
||||
strategy.setStrategyActionList(new ArrayList<>());
|
||||
|
||||
for (MonitorStrategyExpressionDTO elem: monitorDTO.getStrategyExpressionList()) {
|
||||
StrategyExpression strategyExpression = new StrategyExpression();
|
||||
strategyExpression.setMetric(elem.getMetric());
|
||||
strategyExpression.setFunc(elem.getFunc());
|
||||
strategyExpression.setEopt(elem.getEopt());
|
||||
strategyExpression.setThreshold(elem.getThreshold());
|
||||
strategyExpression.setParams(elem.getParams());
|
||||
strategy.getStrategyExpressionList().add(strategyExpression);
|
||||
}
|
||||
|
||||
for (MonitorStrategyFilterDTO elem: monitorDTO.getStrategyFilterList()) {
|
||||
StrategyFilter strategyFilter = new StrategyFilter();
|
||||
strategyFilter.setTkey(elem.getTkey());
|
||||
strategyFilter.setTopt(elem.getTopt());
|
||||
strategyFilter.setTval(ListUtils.strList2String(elem.getTval()));
|
||||
strategy.getStrategyFilterList().add(strategyFilter);
|
||||
}
|
||||
|
||||
for (MonitorStrategyActionDTO elem: monitorDTO.getStrategyActionList()) {
|
||||
StrategyAction strategyAction = new StrategyAction();
|
||||
strategyAction.setNotifyGroup(ListUtils.strList2String(elem.getNotifyGroup()));
|
||||
strategyAction.setConverge(elem.getConverge());
|
||||
strategyAction.setCallback(elem.getCallback());
|
||||
strategy.getStrategyActionList().add(strategyAction);
|
||||
}
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public static MonitorRuleDTO convert2MonitorRuleDTO(MonitorRuleDO monitorRuleDO, Strategy strategy) {
|
||||
MonitorRuleDTO monitorRuleDTO = new MonitorRuleDTO();
|
||||
|
||||
monitorRuleDTO.setId(monitorRuleDO.getId());
|
||||
monitorRuleDTO.setAppId(monitorRuleDO.getAppId());
|
||||
monitorRuleDTO.setName(strategy.getName());
|
||||
monitorRuleDTO.setPriority(strategy.getPriority());
|
||||
monitorRuleDTO.setPeriodHoursOfDay(strategy.getPeriodHoursOfDay());
|
||||
monitorRuleDTO.setPeriodDaysOfWeek(strategy.getPeriodDaysOfWeek());
|
||||
monitorRuleDTO.setStrategyExpressionList(new ArrayList<>());
|
||||
monitorRuleDTO.setStrategyFilterList(new ArrayList<>());
|
||||
monitorRuleDTO.setStrategyActionList(new ArrayList<>());
|
||||
|
||||
for (StrategyExpression elem: strategy.getStrategyExpressionList()) {
|
||||
MonitorStrategyExpressionDTO strategyExpression = new MonitorStrategyExpressionDTO();
|
||||
strategyExpression.setMetric(elem.getMetric());
|
||||
strategyExpression.setFunc(elem.getFunc());
|
||||
strategyExpression.setEopt(elem.getEopt());
|
||||
strategyExpression.setThreshold(elem.getThreshold());
|
||||
strategyExpression.setParams(elem.getParams());
|
||||
monitorRuleDTO.getStrategyExpressionList().add(strategyExpression);
|
||||
}
|
||||
|
||||
for (StrategyFilter elem: strategy.getStrategyFilterList()) {
|
||||
MonitorStrategyFilterDTO strategyFilter = new MonitorStrategyFilterDTO();
|
||||
strategyFilter.setTkey(elem.getTkey());
|
||||
strategyFilter.setTopt(elem.getTopt());
|
||||
strategyFilter.setTval(ListUtils.string2StrList(elem.getTval()));
|
||||
monitorRuleDTO.getStrategyFilterList().add(strategyFilter);
|
||||
}
|
||||
|
||||
for (StrategyAction elem: strategy.getStrategyActionList()) {
|
||||
MonitorStrategyActionDTO strategyAction = new MonitorStrategyActionDTO();
|
||||
strategyAction.setNotifyGroup(ListUtils.string2StrList(elem.getNotifyGroup()));
|
||||
strategyAction.setConverge(elem.getConverge());
|
||||
strategyAction.setCallback(elem.getCallback());
|
||||
monitorRuleDTO.getStrategyActionList().add(strategyAction);
|
||||
}
|
||||
return monitorRuleDTO;
|
||||
}
|
||||
|
||||
public static Silence convert2Silence(MonitorRuleDO monitorRuleDO, MonitorSilenceDTO monitorSilenceDTO) {
|
||||
Silence silence = new Silence();
|
||||
silence.setSilenceId(monitorSilenceDTO.getId());
|
||||
silence.setStrategyId(monitorRuleDO.getStrategyId());
|
||||
silence.setBeginTime(monitorSilenceDTO.getStartTime());
|
||||
silence.setEndTime(monitorSilenceDTO.getEndTime());
|
||||
silence.setDescription(monitorSilenceDTO.getDescription());
|
||||
return silence;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.component;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/30
|
||||
*/
|
||||
public abstract class AbstractMonitorService {
|
||||
/**
|
||||
* 监控策略的增删改查
|
||||
*/
|
||||
public abstract Integer createStrategy(Strategy strategy);
|
||||
|
||||
public abstract Boolean deleteStrategyById(Long strategyId);
|
||||
|
||||
public abstract Boolean modifyStrategy(Strategy strategy);
|
||||
|
||||
public abstract List<Strategy> getStrategies();
|
||||
|
||||
public abstract Strategy getStrategyById(Long strategyId);
|
||||
|
||||
/**
|
||||
* 告警的查
|
||||
*/
|
||||
public abstract List<Alert> getAlerts(Long strategyId, Long startTime, Long endTime);
|
||||
|
||||
public abstract Alert getAlertById(Long alertId);
|
||||
|
||||
/**
|
||||
* 屏蔽的增删改查
|
||||
*/
|
||||
public abstract Boolean createSilence(Silence silence);
|
||||
|
||||
public abstract Boolean releaseSilence(Long silenceId);
|
||||
|
||||
public abstract Boolean modifySilence(Silence silence);
|
||||
|
||||
public abstract List<Silence> getSilences(Long strategyId);
|
||||
|
||||
public abstract Silence getSilenceById(Long silenceId);
|
||||
|
||||
/**
|
||||
* 指标的上报和查询
|
||||
*/
|
||||
public abstract Boolean sinkMetrics(List<MetricSinkPoint> pointList);
|
||||
|
||||
public abstract Metric getMetrics(String metric, Long startTime, Long endTime, Integer step, Properties tags);
|
||||
|
||||
/**
|
||||
* 告警组
|
||||
*/
|
||||
public abstract List<NotifyGroup> getNotifyGroups();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.component.n9e;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.MetricSinkPoint;
|
||||
import com.xiaojukeji.kafka.manager.monitor.component.n9e.entry.N9eMetricSinkPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/26
|
||||
*/
|
||||
public class N9eConverter {
|
||||
public static List<N9eMetricSinkPoint> convert2N9eMetricSinkPointList(List<MetricSinkPoint> pointList) {
|
||||
if (pointList == null || pointList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<N9eMetricSinkPoint> n9ePointList = new ArrayList<>();
|
||||
for (MetricSinkPoint sinkPoint: pointList) {
|
||||
n9ePointList.add(new N9eMetricSinkPoint(
|
||||
sinkPoint.getName(),
|
||||
sinkPoint.getValue(),
|
||||
sinkPoint.getStep(),
|
||||
sinkPoint.getTimestamp(),
|
||||
sinkPoint.getTags()
|
||||
));
|
||||
}
|
||||
return n9ePointList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.component.n9e;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.HttpUtils;
|
||||
import com.xiaojukeji.kafka.manager.monitor.component.AbstractMonitorService;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.*;
|
||||
import com.xiaojukeji.kafka.manager.monitor.component.n9e.entry.N9eResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 夜莺
|
||||
* @author zengqiao
|
||||
* @date 20/4/30
|
||||
*/
|
||||
@Service("abstractMonitor")
|
||||
public class N9eService extends AbstractMonitorService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(N9eService.class);
|
||||
|
||||
@Value("${monitor.n9e.base-url}")
|
||||
private String monitorN9eBaseUrl;
|
||||
|
||||
/**
|
||||
* 告警策略
|
||||
*/
|
||||
private static final String STRATEGY_ADD_URL = "/auth/v1/strategy/add";
|
||||
|
||||
private static final String STRATEGY_DEL_URL = "/auth/v1/strategy/del";
|
||||
|
||||
private static final String STRATEGY_MODIFY_URL = "/auth/v1/strategy/modify";
|
||||
|
||||
private static final String STRATEGY_QUERY_BY_NS_URL = "/auth/v1/strategy/query/ns";
|
||||
|
||||
private static final String STRATEGY_QUERY_BY_ID_URL = "/auth/v1/strategy/query/id";
|
||||
|
||||
private static final String ALERT_QUERY_BY_NS_AND_PERIOD_URL = "/auth/v1/event/query/ns/period";
|
||||
|
||||
private static final String ALERT_QUERY_BY_ID_URL = "/auth/v1/event/query/id";
|
||||
|
||||
/**
|
||||
* 告警屏蔽
|
||||
*/
|
||||
private static final String SILENCE_ADD_URL = "/auth/v1/silence/add";
|
||||
|
||||
private static final String SILENCE_RELEASE_URL = "/auth/v1/silence/release";
|
||||
|
||||
private static final String SILENCE_MODIFY_URL = "/auth/v1/silence/modify";
|
||||
|
||||
private static final String SILENCE_QUERY_BY_NS_URL = "/auth/v1/silence/query/ns";
|
||||
|
||||
/**
|
||||
* 指标数据
|
||||
*/
|
||||
private static final String COLLECTOR_SINK_DATA_URL = "/api/collector/push";
|
||||
|
||||
private static final String COLLECTOR_DOWNLOAD_DATA_URL = "/data/query/graph/dashboard/history";
|
||||
|
||||
/**
|
||||
* 告警组
|
||||
*/
|
||||
private static final String ALL_NOTIFY_GROUP_URL = "/auth/v1/usergroup/group/all";
|
||||
|
||||
/**
|
||||
* 监控策略的增删改查
|
||||
*/
|
||||
@Override
|
||||
public Integer createStrategy(Strategy strategy) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteStrategyById(Long strategyId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean modifyStrategy(Strategy strategy) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Strategy> getStrategies() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Strategy getStrategyById(Long strategyId) {
|
||||
return new Strategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Alert> getAlerts(Long strategyId, Long startTime, Long endTime) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alert getAlertById(Long alertId) {
|
||||
return new Alert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean createSilence(Silence silence) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean releaseSilence(Long silenceId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean modifySilence(Silence silence) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Silence> getSilences(Long strategyId) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Silence getSilenceById(Long silenceId) {
|
||||
return new Silence();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sinkMetrics(List<MetricSinkPoint> pointList) {
|
||||
String response = null;
|
||||
try {
|
||||
String content = JSON.toJSONString(N9eConverter.convert2N9eMetricSinkPointList(pointList));
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
response = HttpUtils.postForString(
|
||||
monitorN9eBaseUrl + COLLECTOR_SINK_DATA_URL,
|
||||
content,
|
||||
null
|
||||
);
|
||||
LOGGER.info("sinkMetrics cost-time:{}.", System.currentTimeMillis() - startTime);
|
||||
|
||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
||||
if (n9eResult.getErr() != null && !n9eResult.getErr().isEmpty()) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("sink metrics failed, pointList:{}.", pointList, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metric getMetrics(String metric, Long startTime, Long endTime, Integer step, Properties tags) {
|
||||
return new Metric();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotifyGroup> getNotifyGroups() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.component.n9e.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.sink.MonitorBaseSinkTag;
|
||||
|
||||
/**
|
||||
* 夜莺上报监控数据点
|
||||
* @author zengqiao
|
||||
* @date 20/8/26
|
||||
*/
|
||||
public class N9eMetricSinkPoint {
|
||||
/**
|
||||
* 指标名
|
||||
*/
|
||||
private String metric;
|
||||
|
||||
/**
|
||||
* 指标对应的机器
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* 指标值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 上报周期
|
||||
*/
|
||||
private int step;
|
||||
|
||||
/**
|
||||
* 当前时间戳,单位为s
|
||||
*/
|
||||
private long timestamp;
|
||||
|
||||
/**
|
||||
* tags
|
||||
*/
|
||||
private MonitorBaseSinkTag tags;
|
||||
|
||||
public N9eMetricSinkPoint(String metric,
|
||||
String value,
|
||||
int step,
|
||||
long timestamp,
|
||||
MonitorBaseSinkTag tags) {
|
||||
this.metric = metric;
|
||||
this.endpoint = tags.getHost();
|
||||
this.value = value;
|
||||
this.step = step;
|
||||
this.timestamp = timestamp;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(int step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public MonitorBaseSinkTag getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(MonitorBaseSinkTag tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "N9eMetricSinkPoint{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", endpoint='" + endpoint + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", step=" + step +
|
||||
", timestamp=" + timestamp +
|
||||
", tags=" + tags +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.component.n9e.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/26
|
||||
*/
|
||||
public class N9eResult<T> {
|
||||
private T dat;
|
||||
|
||||
private String err;
|
||||
|
||||
public T getDat() {
|
||||
return dat;
|
||||
}
|
||||
|
||||
public void setDat(T dat) {
|
||||
this.dat = dat;
|
||||
}
|
||||
|
||||
public String getErr() {
|
||||
return err;
|
||||
}
|
||||
|
||||
public void setErr(String err) {
|
||||
this.err = err;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "N9eResult{" +
|
||||
"dat=" + dat +
|
||||
", err='" + err + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorRuleDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorSilenceDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorAlertDetail;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorRuleSummary;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.MonitorRuleDao;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AppDao;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.utils.CommonConverter;
|
||||
import com.xiaojukeji.kafka.manager.monitor.component.AbstractMonitorService;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.*;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.MonitorService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
@Service("monitorService")
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AbstractMonitorService abstractMonitor;
|
||||
|
||||
@Autowired
|
||||
private MonitorRuleDao monitorRuleDao;
|
||||
|
||||
@Autowired
|
||||
private AppDao appDao;
|
||||
|
||||
@Override
|
||||
public ResultStatus createMonitorRule(MonitorRuleDTO monitorRuleDTO, String operator) {
|
||||
Integer strategyId = abstractMonitor.createStrategy(
|
||||
CommonConverter.convert2Strategy(null, monitorRuleDTO)
|
||||
);
|
||||
if (ValidateUtils.isNull(strategyId)) {
|
||||
return ResultStatus.CALL_MONITOR_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
MonitorRuleDO monitorRuleDO = new MonitorRuleDO();
|
||||
monitorRuleDO.setAppId(monitorRuleDTO.getAppId());
|
||||
monitorRuleDO.setName(monitorRuleDTO.getName());
|
||||
monitorRuleDO.setOperator(operator);
|
||||
monitorRuleDO.setStrategyId(strategyId.longValue());
|
||||
try {
|
||||
if (monitorRuleDao.insert(monitorRuleDO) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("create monitor rule failed, monitorRuleDTO:{}.", monitorRuleDTO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus deleteMonitorRule(Long id, String operator) {
|
||||
MonitorRuleDO monitorRuleDO = this.getById(id);
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return ResultStatus.MONITOR_NOT_EXIST;
|
||||
}
|
||||
Boolean status = abstractMonitor.deleteStrategyById(monitorRuleDO.getStrategyId());
|
||||
if (!status) {
|
||||
return ResultStatus.CALL_MONITOR_SYSTEM_ERROR;
|
||||
}
|
||||
try {
|
||||
if (monitorRuleDao.deleteById(id) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("delete monitor rule failed, id:{}.", id, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus modifyMonitorRule(MonitorRuleDTO monitorRuleDTO, String operator) {
|
||||
MonitorRuleDO monitorRuleDO = this.getById(monitorRuleDTO.getId());
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return ResultStatus.MONITOR_NOT_EXIST;
|
||||
}
|
||||
Boolean status = abstractMonitor.modifyStrategy(
|
||||
CommonConverter.convert2Strategy(monitorRuleDO.getStrategyId(), monitorRuleDTO)
|
||||
);
|
||||
if (!status) {
|
||||
return ResultStatus.CALL_MONITOR_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
try {
|
||||
if (monitorRuleDao.updateById(
|
||||
monitorRuleDTO.getId(),
|
||||
monitorRuleDTO.getName(),
|
||||
monitorRuleDTO.getAppId(),
|
||||
operator) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("modify monitor rule failed, monitorRuleDTO:{}.", monitorRuleDTO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonitorRuleSummary> getMonitorRules(String operator) {
|
||||
List<MonitorRuleDO> monitorRuleDOList = this.listAll();
|
||||
if (ValidateUtils.isEmptyList(monitorRuleDOList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AppDO> appDOList = appDao.getByPrincipal(operator);
|
||||
if (ValidateUtils.isEmptyList(appDOList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, AppDO> appMap = new HashMap<>();
|
||||
for (AppDO appDO: appDOList) {
|
||||
appMap.put(appDO.getAppId(), appDO);
|
||||
}
|
||||
|
||||
List<MonitorRuleSummary> summaryList = new ArrayList<>();
|
||||
for (MonitorRuleDO elem: monitorRuleDOList) {
|
||||
AppDO appDO = appMap.get(elem.getAppId());
|
||||
if (ValidateUtils.isNull(appDO)) {
|
||||
continue;
|
||||
}
|
||||
MonitorRuleSummary summary = new MonitorRuleSummary();
|
||||
summary.setId(elem.getId());
|
||||
summary.setName(elem.getName());
|
||||
summary.setAppId(elem.getAppId());
|
||||
summary.setAppName(appDO.getName());
|
||||
summary.setPrincipals(appDO.getPrincipals());
|
||||
summary.setOperator(elem.getOperator());
|
||||
summary.setCreateTime(elem.getCreateTime().getTime());
|
||||
summaryList.add(summary);
|
||||
}
|
||||
return summaryList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MonitorRuleDTO> getMonitorRuleDetail(MonitorRuleDO monitorRuleDO) {
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return Result.buildFrom(ResultStatus.MONITOR_NOT_EXIST);
|
||||
}
|
||||
Strategy strategy = abstractMonitor.getStrategyById(monitorRuleDO.getStrategyId());
|
||||
if (ValidateUtils.isNull(strategy)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
MonitorRuleDTO monitorRuleDTO = CommonConverter.convert2MonitorRuleDTO(monitorRuleDO, strategy);
|
||||
monitorRuleDTO.setId(monitorRuleDO.getId());
|
||||
monitorRuleDTO.setAppId(monitorRuleDO.getAppId());
|
||||
return new Result<>(monitorRuleDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Alert>> getMonitorAlertHistory(Long id, Long startTime, Long endTime) {
|
||||
MonitorRuleDO monitorRuleDO = this.getById(id);
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return Result.buildFrom(ResultStatus.MONITOR_NOT_EXIST);
|
||||
}
|
||||
List<Alert> alertList =
|
||||
abstractMonitor.getAlerts(monitorRuleDO.getStrategyId(), startTime / 1000, endTime / 1000);
|
||||
if (ValidateUtils.isNull(alertList)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
return new Result<>(alertList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MonitorAlertDetail> getMonitorAlertDetail(Long alertId) {
|
||||
Alert alert = abstractMonitor.getAlertById(alertId);
|
||||
if (ValidateUtils.isNull(alert)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
MonitorRuleDO monitorRuleDO = this.getByStrategyId(alert.getStrategyId());
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return Result.buildFrom(ResultStatus.MONITOR_NOT_EXIST);
|
||||
}
|
||||
alert.setMonitorId(monitorRuleDO.getId());
|
||||
|
||||
Metric metric = abstractMonitor.getMetrics(alert.getMetric(),
|
||||
(alert.getStartTime() - 3600) * 1000 ,
|
||||
(alert.getEndTime() + 3600) * 1000,
|
||||
60,
|
||||
alert.getTags());
|
||||
|
||||
return new Result<>(new MonitorAlertDetail(alert, metric));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonitorRuleDO getById(Long id) {
|
||||
try {
|
||||
return monitorRuleDao.getById(id);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get monitor rule failed, id:{}.", id, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonitorRuleDO getByStrategyId(Long strategyId) {
|
||||
try {
|
||||
return monitorRuleDao.getByStrategyId(strategyId);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get monitor rule failed, strategyId:{}.", strategyId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<MonitorRuleDO> listAll() {
|
||||
try {
|
||||
return monitorRuleDao.listAll();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get all monitor rule failed.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result createSilence(MonitorSilenceDTO monitorSilenceDTO, String operator) {
|
||||
MonitorRuleDO monitorRuleDO = this.getById(monitorSilenceDTO.getMonitorId());
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return Result.buildFrom(ResultStatus.MONITOR_NOT_EXIST);
|
||||
}
|
||||
|
||||
Boolean status = abstractMonitor.createSilence(
|
||||
CommonConverter.convert2Silence(monitorRuleDO, monitorSilenceDTO)
|
||||
);
|
||||
if (status) {
|
||||
return new Result();
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean releaseSilence(Long silenceId) {
|
||||
if (ValidateUtils.isNull(silenceId)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return abstractMonitor.releaseSilence(silenceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result modifySilence(MonitorSilenceDTO monitorSilenceDTO, String operator) {
|
||||
MonitorRuleDO monitorRuleDO = this.getById(monitorSilenceDTO.getMonitorId());
|
||||
if (ValidateUtils.isNull(monitorRuleDO)) {
|
||||
return Result.buildFrom(ResultStatus.MONITOR_NOT_EXIST);
|
||||
}
|
||||
Boolean status = abstractMonitor.modifySilence(
|
||||
CommonConverter.convert2Silence(monitorRuleDO, monitorSilenceDTO)
|
||||
);
|
||||
if (status) {
|
||||
return new Result();
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Silence>> getSilences(Long monitorId) {
|
||||
List<Silence> silenceList = abstractMonitor.getSilences(monitorId);
|
||||
if (ValidateUtils.isNull(silenceList)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_MONITOR_SYSTEM_ERROR);
|
||||
}
|
||||
return new Result<>(silenceList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Silence getSilenceById(Long silenceId) {
|
||||
if (ValidateUtils.isNull(silenceId)) {
|
||||
return null;
|
||||
}
|
||||
return abstractMonitor.getSilenceById(silenceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotifyGroup> getNotifyGroups() {
|
||||
return abstractMonitor.getNotifyGroups();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
monitor:
|
||||
n9e:
|
||||
base-url: http://127.0.0.1/api
|
||||
Reference in New Issue
Block a user