diff --git a/web/src/api/prometheus.ts b/web/src/api/prometheus.ts
index 257a33fe069464d1fd383a61af9236908aa6f65f..1a05beeb5b3f0ea51df5ad7edcbd201236bf6953 100644
--- a/web/src/api/prometheus.ts
+++ b/web/src/api/prometheus.ts
@@ -41,6 +41,14 @@ export function getRuleList(data: Object) {
params: data,
});
}
+// 添加告警告警规则
+export function addConfigRule(data: object) {
+ return request({
+ url: "/plugin/prometheus/ruleAdd",
+ method: "post",
+ data,
+ });
+}
// 获取所有监控指标
export function getMetrics() {
return request({
diff --git a/web/src/types/host.ts b/web/src/types/host.ts
new file mode 100644
index 0000000000000000000000000000000000000000..f27b4a1099f261b732c0c0b3f47ea4e7a7de3f1f
--- /dev/null
+++ b/web/src/types/host.ts
@@ -0,0 +1,12 @@
+export interface Host {
+ hostId: number,
+ targetIp: string,
+ deptName: string,
+ agentStatus: string,
+ operatingSystem: string,
+ monitorAgentStatus: string,
+ version: string,
+ monitorVersion: string,
+ architecture: string,
+ registTime: string
+}
\ No newline at end of file
diff --git a/web/src/types/rule.ts b/web/src/types/rule.ts
new file mode 100644
index 0000000000000000000000000000000000000000..cce61ffb5d2868708f88d29e31cf5f68e5ceec64
--- /dev/null
+++ b/web/src/types/rule.ts
@@ -0,0 +1,17 @@
+export interface ConfigRule {
+ id?: number;
+ metrics: string;
+ ips?: string[];
+ batches: any[];
+ batches_str: string;
+ alertTargets: any[];
+ alertHostIds?: string;
+ alertLabel: string;
+ alertName: string;
+ duration: number | string;
+ severity: string;
+ input_severity?: string;
+ threshold: number | string;
+ desc: string;
+ [key: string]: unknown;
+}
diff --git a/web/src/views/ruleForm/addRule.vue b/web/src/views/ruleForm/addRule.vue
new file mode 100644
index 0000000000000000000000000000000000000000..e41b0a348db06056322fcc773cbaa354587e5b12
--- /dev/null
+++ b/web/src/views/ruleForm/addRule.vue
@@ -0,0 +1,362 @@
+
+
+
+
+
+
+
+ 选择主机IP
+
+
+
+
+ 暂无数据
+
+
+
+
+
+
+ 暂无数据
+
+
+
+
+
+
+
+ 暂无数据
+
+
+
+
+
+ 选择告警级别
+ 自定义告警级别
+
+
+
+
+ 暂无数据
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ e.preventDefault()">确定
+
+
+
+
+
+
diff --git a/web/src/views/ruleForm/customRule.ts b/web/src/views/ruleForm/customRule.ts
new file mode 100644
index 0000000000000000000000000000000000000000..0aeac2831d1b0bec8778f9c350deb38830783c28
--- /dev/null
+++ b/web/src/views/ruleForm/customRule.ts
@@ -0,0 +1,30 @@
+// 自定义校验
+
+// 校验阈值是否在0-100之间
+export const checkThreshold = (rule: any, value: any, callback: any) => {
+ setTimeout(() => {
+ if (!Number.isInteger(parseInt(value))) {
+ callback(new Error('请输入数字'))
+ } else {
+ if (value < 0 || value > 100) {
+ callback(new Error('请输入0-100之间的数字'))
+ } else {
+ callback()
+ }
+ }
+ }, 100)
+}
+
+export const checkDuration = (rule: any, value: any, callback: any) => {
+ setTimeout(() => {
+ if (isNaN(value)) {
+ callback(new Error('请输入数字'))
+ } else {
+ if (value < 0) {
+ callback(new Error('请输入大于等于0的数字'))
+ } else {
+ callback()
+ }
+ }
+ }, 100)
+}
\ No newline at end of file
diff --git a/web/src/views/ruleList.vue b/web/src/views/ruleList.vue
index 557ae3bbccfdbfcb5e859e5de7bbc1ef6114ed59..23a4aa62da7c5070c9990c742ba32c5fd13c1c46 100644
--- a/web/src/views/ruleList.vue
+++ b/web/src/views/ruleList.vue
@@ -12,6 +12,10 @@
@input="searchInputKey" />
+
+ e.preventDefault()">新增
+
@@ -48,12 +52,17 @@
+
+
+