Compare commits

..

14 Commits

Author SHA1 Message Date
openeuler-ci-bot
71e5e03022
!43 同步sp3修改至sp4 分支,修复版本降级issues
From: @weidongkl 
Reviewed-by: @Lostwayzxc 
Signed-off-by: @Lostwayzxc
2024-05-31 03:42:48 +00:00
weidongkl
2ef17786f6
sync: 同步sp3修改
Signed-off-by: weidongkl <weidong@uniontech.com>
2024-05-28 14:11:02 +08:00
openeuler-ci-bot
964354526e
!35 [sync] PR-34: update spec requires
From: @openeuler-sync-bot 
Reviewed-by: @Lostwayzxc 
Signed-off-by: @Lostwayzxc
2023-12-23 02:26:08 +00:00
rabbitali
a642eba4cf update spec requires
(cherry picked from commit 20ba78cbfd859da5362e3325fcc1456d4d747c21)
2023-09-21 20:07:40 +08:00
openeuler-ci-bot
71e3d59d96
!33 [sync] PR-31: 添加sql脚本
From: @openeuler-sync-bot 
Reviewed-by: @zhu-yuncheng 
Signed-off-by: @zhu-yuncheng
2023-09-21 12:06:03 +00:00
rabbitali
035f022f74 add diana sql script
(cherry picked from commit 0186cb163dbc3ffa6256151d35d45e8b365694e5)
2023-09-19 11:43:51 +08:00
openeuler-ci-bot
84d78212ea
!28 [sync] PR-27: 更新diana版本至v1.3.0
From: @openeuler-sync-bot 
Reviewed-by: @zhu-yuncheng 
Signed-off-by: @zhu-yuncheng
2023-09-12 01:33:04 +00:00
zhu-yuncheng
91418dd3c1 update to version 1.3.0
(cherry picked from commit fe16165b74d217cdb80e709672bb62eff0cb830d)
2023-09-11 22:27:32 +08:00
openeuler-ci-bot
c909920738
!24 发布1.2.0版本
From: @gongzt 
Reviewed-by: @zhu-yuncheng 
Signed-off-by: @zhu-yuncheng
2023-04-17 14:33:30 +00:00
gongzhengtang
112ecfbc20 解决spec冲突
Signed-off-by: gongzhengtang <gong_zhengtang@163.com>
2023-04-17 14:23:58 +00:00
openeuler-ci-bot
2402b5157b
!8 [sync] PR-5: 更新至v1.1.1版本
From: @openeuler-sync-bot 
Reviewed-by: @Lostwayzxc 
Signed-off-by: @Lostwayzxc
2022-12-02 09:31:40 +00:00
zhu-yuncheng
6036b26987 upgrade to v1.1.1
(cherry picked from commit 603e6766492dc95758a7ef080033cdb042eaff05)
2022-12-02 16:45:22 +08:00
openeuler-ci-bot
0c076b8645
!4 [sync] PR-1: add package aops-diana,version 1.0.0
From: @openeuler-sync-bot 
Reviewed-by: @zhu-yuncheng 
Signed-off-by: @zhu-yuncheng
2022-11-22 14:31:09 +00:00
wenxin
5c0a63410c add package
(cherry picked from commit d4f6ecd5b8db91abd963ae5600a0d9004c8ff852)
2022-11-22 22:30:00 +08:00
5 changed files with 497 additions and 4 deletions

View File

@ -0,0 +1,273 @@
From 0298776c0ae0ce230d2993b570abc68c9b3f9f42 Mon Sep 17 00:00:00 2001
From: gongzt <gong_zhengtang@163.com>
Date: Tue, 19 Sep 2023 10:29:18 +0800
Subject: [PATCH 1/1] add the sql script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
aops-diana.spec | 10 ++-
database/diana.sql | 88 ++++++++++++++++++++++++
doc/design/aops-diana数据库设计.sql | 54 +++++++--------
setup.py | 3 +-
4 files changed, 122 insertions(+), 33 deletions(-)
create mode 100644 database/diana.sql
diff --git a/aops-diana.spec b/aops-diana.spec
index 259956e..ef6fcd2 100644
--- a/aops-diana.spec
+++ b/aops-diana.spec
@@ -1,5 +1,5 @@
Name: aops-diana
-Version: v1.2.0
+Version: v1.3.0
Release: 1
Summary: An intelligent abnormal detection framework of aops
License: MulanPSL2
@@ -9,7 +9,7 @@ Source0: %{name}-%{version}.tar.gz
BuildRequires: python3-setuptools
Requires: aops-vulcanus >= v1.2.0
Requires: python3-requests python3-flask python3-flask-restful python3-marshmallow >= 3.13.0
-Requires: python3-numpy python3-pandas python3-prometheus-api-client
+Requires: python3-numpy python3-pandas python3-prometheus-api-client python3-uWSGI
Requires: python3-sqlalchemy python3-PyMySQL python3-Flask-APScheduler >= 1.11.0
Requires: python3-scipy python3-adtk
Provides: aops-diana
@@ -30,6 +30,8 @@ An intelligent abnormal detection framework of aops
# install for aops-diana
%py3_install
+mkdir -p %{buildroot}/opt/aops/
+cp -r database %{buildroot}/opt/aops/
%files
@@ -42,9 +44,13 @@ An intelligent abnormal detection framework of aops
%attr(0755,root,root) /usr/lib/systemd/system/aops-diana.service
%{python3_sitelib}/aops_diana*.egg-info
%{python3_sitelib}/diana/*
+%attr(0755, root, root) /opt/aops/database/*
%changelog
+* Mon Sep 18 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.0-1
+- Support sql script to create tables
+
* Fri Mar 24 2023 gongzhengtang<gong_zhengtang@163.com> - v1.2.0-1
- update the structure of response body; update how to get session used to
- connect to the database
diff --git a/database/diana.sql b/database/diana.sql
new file mode 100644
index 0000000..d4452c4
--- /dev/null
+++ b/database/diana.sql
@@ -0,0 +1,88 @@
+use aops;
+
+CREATE TABLE IF NOT EXISTS `domain_check_result` (
+ `alert_id` CHAR(32) NOT NULL,
+ `domain` CHAR(20) NOT NULL,
+ `alert_name` CHAR(50) NULL,
+ `time` INT(11) NULL,
+ `workflow_name` CHAR(50) NULL,
+ `workflow_id` CHAR(32) NULL,
+ `username` CHAR(20) NULL,
+ `level` CHAR(20) NULL,
+ `confirmed` TINYINT(1) NULL,
+ PRIMARY KEY (`alert_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `alert_host` (
+ `alert_id` CHAR(32) NOT NULL,
+ `host_id` CHAR(32) NOT NULL,
+ `host_ip` CHAR(32) NULL,
+ `host_name` CHAR(50) NULL,
+ PRIMARY KEY (`host_id`,`alert_id`),
+ KEY `FK__alert_id_auto_index` (`alert_id`),
+ KEY `FK_alert_with_host_host_id_auto_index` (`host_id`),
+ CONSTRAINT `FK_alert_host_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `algorithm` (
+ `algo_id` INT(11) NOT NULL,
+ `path` CHAR(150) NULL,
+ `username` CHAR(10) NULL,
+ `algo_name` CHAR(20) NOT NULL,
+ `field` CHAR(20) NOT NULL,
+ `description` LONGTEXT NULL,
+ PRIMARY KEY (`algo_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `host_check_result` (
+ `id` INT(11) NOT NULL,
+ `time` INT(11) NOT NULL,
+ `is_root` TINYINT(1) NULL,
+ `host_id` CHAR(32) NOT NULL,
+ `metric_name` CHAR(50) NULL,
+ `alert_id` CHAR(32) NOT NULL,
+ `metric_label` CHAR(255) NULL,
+ PRIMARY KEY (`id`),
+ KEY `host_id_auto_index` (`host_id`),
+ KEY `alert_id_auto_index` (`alert_id`),
+ CONSTRAINT `FK_host_check_result_host_id` FOREIGN KEY (`host_id`) REFERENCES `alert_host` (`host_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ,
+ CONSTRAINT `FK_host_check_result_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `model` (
+ `model_id` INT(11) NOT NULL,
+ `username` CHAR(40) NULL,
+ `model_name` CHAR(10) NULL,
+ `tag` CHAR(255) NULL,
+ `algo_id` INT(11) NULL,
+ `create_time` INT(11) NULL,
+ `file_path` CHAR(64) NULL,
+ `precision` DOUBLE NULL,
+ PRIMARY KEY (`model_id`),
+ KEY `algo_id_auto_index` (`algo_id`),
+ CONSTRAINT `FK_model_algo_id` FOREIGN KEY (`algo_id`) REFERENCES `algorithm` (`algo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `workflow` (
+ `workflow_id` CHAR(20) NOT NULL,
+ `workflow_name` CHAR(10) NOT NULL,
+ `status` CHAR(12) NOT NULL,
+ `description` CHAR(50) NULL,
+ `app_name` CHAR(10) NOT NULL,
+ `app_id` CHAR(10) NOT NULL,
+ `step` INT(11) NOT NULL,
+ `period` INT(11) NOT NULL,
+ `domain` CHAR(20) NOT NULL,
+ `username` CHAR(40) NOT NULL,
+ PRIMARY KEY (`workflow_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
+CREATE TABLE IF NOT EXISTS `workflow_host` (
+ `host_id` CHAR(32) NOT NULL,
+ `workflow_id` CHAR(10) NULL,
+ `host_name` CHAR(20) NULL,
+ `host_ip` CHAR(16) NULL,
+ PRIMARY KEY (`host_id`),
+ KEY `workflow_id_auto_index` (`workflow_id`),
+ CONSTRAINT `FK_workflow_workflow_id` FOREIGN KEY (`workflow_id`) REFERENCES `workflow` (`workflow_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
diff --git a/doc/design/aops-diana数据库设计.sql b/doc/design/aops-diana数据库设计.sql
index 33e05f8..d4452c4 100644
--- a/doc/design/aops-diana数据库设计.sql
+++ b/doc/design/aops-diana数据库设计.sql
@@ -1,3 +1,18 @@
+use aops;
+
+CREATE TABLE IF NOT EXISTS `domain_check_result` (
+ `alert_id` CHAR(32) NOT NULL,
+ `domain` CHAR(20) NOT NULL,
+ `alert_name` CHAR(50) NULL,
+ `time` INT(11) NULL,
+ `workflow_name` CHAR(50) NULL,
+ `workflow_id` CHAR(32) NULL,
+ `username` CHAR(20) NULL,
+ `level` CHAR(20) NULL,
+ `confirmed` TINYINT(1) NULL,
+ PRIMARY KEY (`alert_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+
CREATE TABLE IF NOT EXISTS `alert_host` (
`alert_id` CHAR(32) NOT NULL,
`host_id` CHAR(32) NOT NULL,
@@ -5,7 +20,8 @@ CREATE TABLE IF NOT EXISTS `alert_host` (
`host_name` CHAR(50) NULL,
PRIMARY KEY (`host_id`,`alert_id`),
KEY `FK__alert_id_auto_index` (`alert_id`),
- KEY `FK_alert_with_host_host_id_auto_index` (`host_id`)
+ KEY `FK_alert_with_host_host_id_auto_index` (`host_id`),
+ CONSTRAINT `FK_alert_host_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
CREATE TABLE IF NOT EXISTS `algorithm` (
@@ -18,19 +34,6 @@ CREATE TABLE IF NOT EXISTS `algorithm` (
PRIMARY KEY (`algo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
-CREATE TABLE IF NOT EXISTS `domain_check_result` (
- `alert_id` CHAR(32) NOT NULL,
- `domain` CHAR(20) NOT NULL,
- `alert_name` CHAR(50) NULL,
- `time` INT(11) NULL,
- `workflow_name` CHAR(50) NULL,
- `workflow_id` CHAR(32) NULL,
- `username` CHAR(20) NULL,
- `level` CHAR(20) NULL,
- `confirmed` TINYINT(1) NULL,
- PRIMARY KEY (`alert_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
-
CREATE TABLE IF NOT EXISTS `host_check_result` (
`id` INT(11) NOT NULL,
`time` INT(11) NOT NULL,
@@ -41,7 +44,9 @@ CREATE TABLE IF NOT EXISTS `host_check_result` (
`metric_label` CHAR(255) NULL,
PRIMARY KEY (`id`),
KEY `host_id_auto_index` (`host_id`),
- KEY `alert_id_auto_index` (`alert_id`)
+ KEY `alert_id_auto_index` (`alert_id`),
+ CONSTRAINT `FK_host_check_result_host_id` FOREIGN KEY (`host_id`) REFERENCES `alert_host` (`host_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ,
+ CONSTRAINT `FK_host_check_result_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
CREATE TABLE IF NOT EXISTS `model` (
@@ -54,7 +59,8 @@ CREATE TABLE IF NOT EXISTS `model` (
`file_path` CHAR(64) NULL,
`precision` DOUBLE NULL,
PRIMARY KEY (`model_id`),
- KEY `algo_id_auto_index` (`algo_id`)
+ KEY `algo_id_auto_index` (`algo_id`),
+ CONSTRAINT `FK_model_algo_id` FOREIGN KEY (`algo_id`) REFERENCES `algorithm` (`algo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
CREATE TABLE IF NOT EXISTS `workflow` (
@@ -77,18 +83,6 @@ CREATE TABLE IF NOT EXISTS `workflow_host` (
`host_name` CHAR(20) NULL,
`host_ip` CHAR(16) NULL,
PRIMARY KEY (`host_id`),
- KEY `workflow_id_auto_index` (`workflow_id`)
+ KEY `workflow_id_auto_index` (`workflow_id`),
+ CONSTRAINT `FK_workflow_workflow_id` FOREIGN KEY (`workflow_id`) REFERENCES `workflow` (`workflow_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
-
-ALTER TABLE alert_host
-ADD CONSTRAINT `FK_alert_with_host_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;
-
-ALTER TABLE host_check_result
-ADD CONSTRAINT `host_id` FOREIGN KEY (`host_id`) REFERENCES `alert_host` (`host_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ,
-ADD CONSTRAINT `alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;
-
-ALTER TABLE model
-ADD CONSTRAINT `algo_id` FOREIGN KEY (`algo_id`) REFERENCES `algorithm` (`algo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;
-
-ALTER TABLE workflow_host
-ADD CONSTRAINT `workflow_id` FOREIGN KEY (`workflow_id`) REFERENCES `workflow` (`workflow_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;
\ No newline at end of file
diff --git a/setup.py b/setup.py
index fe81380..78b696a 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from setuptools import setup, find_packages
NAME = "aops-diana"
-VERSION = "1.1.0"
+VERSION = "1.3.0"
# To install the library, run the following
#
@@ -60,6 +60,7 @@ setup(
('/etc/aops/algorithm/intelligent/lvs', ['conf/model/intelligent/lvs/rule1_gala_gopher_cpu_net_rx']),
('/etc/aops/algorithm/intelligent/lvs', ['conf/model/intelligent/lvs/rule2_gala_gopher_nic_tc_backlog']),
('/usr/lib/systemd/system', ['aops-diana.service']),
+ ("/opt/aops/database", ["database/diana.sql"]),
],
scripts=['aops-diana'],
zip_safe=False,
--
2.33.1.windows.1

View File

@ -0,0 +1,201 @@
From d29fa8f2fa6e5f23d9462b438a3dd5cf29a4bb02 Mon Sep 17 00:00:00 2001
From: gongzt <gong_zhengtang@163.com>
Date: Mon, 25 Sep 2023 18:30:28 +0800
Subject: fix database type error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
database/diana.sql | 146 +++++++++++++++++-----------------
diana/database/dao/app_dao.py | 4 +-
2 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/database/diana.sql b/database/diana.sql
index d4452c4..a251f21 100644
--- a/database/diana.sql
+++ b/database/diana.sql
@@ -1,88 +1,88 @@
use aops;
CREATE TABLE IF NOT EXISTS `domain_check_result` (
- `alert_id` CHAR(32) NOT NULL,
- `domain` CHAR(20) NOT NULL,
- `alert_name` CHAR(50) NULL,
- `time` INT(11) NULL,
- `workflow_name` CHAR(50) NULL,
- `workflow_id` CHAR(32) NULL,
- `username` CHAR(20) NULL,
- `level` CHAR(20) NULL,
- `confirmed` TINYINT(1) NULL,
- PRIMARY KEY (`alert_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `alert_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `domain` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `alert_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `time` int NOT NULL,
+ `workflow_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `workflow_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `level` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `confirmed` tinyint(1) NULL DEFAULT NULL,
+ PRIMARY KEY (`alert_id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `alert_host` (
- `alert_id` CHAR(32) NOT NULL,
- `host_id` CHAR(32) NOT NULL,
- `host_ip` CHAR(32) NULL,
- `host_name` CHAR(50) NULL,
- PRIMARY KEY (`host_id`,`alert_id`),
- KEY `FK__alert_id_auto_index` (`alert_id`),
- KEY `FK_alert_with_host_host_id_auto_index` (`host_id`),
- CONSTRAINT `FK_alert_host_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `host_id` int NOT NULL,
+ `alert_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `host_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `host_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ PRIMARY KEY (`host_id`, `alert_id`) USING BTREE,
+ INDEX `alert_id`(`alert_id`) USING BTREE,
+ CONSTRAINT `alert_host_ibfk_1` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE CASCADE ON UPDATE RESTRICT
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `algorithm` (
- `algo_id` INT(11) NOT NULL,
- `path` CHAR(150) NULL,
- `username` CHAR(10) NULL,
- `algo_name` CHAR(20) NOT NULL,
- `field` CHAR(20) NOT NULL,
- `description` LONGTEXT NULL,
- PRIMARY KEY (`algo_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `algo_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `algo_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `field` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `path` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `username` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ PRIMARY KEY (`algo_id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `host_check_result` (
- `id` INT(11) NOT NULL,
- `time` INT(11) NOT NULL,
- `is_root` TINYINT(1) NULL,
- `host_id` CHAR(32) NOT NULL,
- `metric_name` CHAR(50) NULL,
- `alert_id` CHAR(32) NOT NULL,
- `metric_label` CHAR(255) NULL,
- PRIMARY KEY (`id`),
- KEY `host_id_auto_index` (`host_id`),
- KEY `alert_id_auto_index` (`alert_id`),
- CONSTRAINT `FK_host_check_result_host_id` FOREIGN KEY (`host_id`) REFERENCES `alert_host` (`host_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ,
- CONSTRAINT `FK_host_check_result_alert_id` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `id` int NOT NULL AUTO_INCREMENT,
+ `host_id` int NULL DEFAULT NULL,
+ `alert_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `time` int NOT NULL,
+ `is_root` tinyint(1) NULL DEFAULT NULL,
+ `metric_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `metric_label` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ INDEX `host_id`(`host_id`) USING BTREE,
+ INDEX `alert_id`(`alert_id`) USING BTREE,
+ CONSTRAINT `host_check_result_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `alert_host` (`host_id`) ON DELETE CASCADE ON UPDATE RESTRICT,
+ CONSTRAINT `host_check_result_ibfk_2` FOREIGN KEY (`alert_id`) REFERENCES `domain_check_result` (`alert_id`) ON DELETE CASCADE ON UPDATE RESTRICT
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `model` (
- `model_id` INT(11) NOT NULL,
- `username` CHAR(40) NULL,
- `model_name` CHAR(10) NULL,
- `tag` CHAR(255) NULL,
- `algo_id` INT(11) NULL,
- `create_time` INT(11) NULL,
- `file_path` CHAR(64) NULL,
- `precision` DOUBLE NULL,
- PRIMARY KEY (`model_id`),
- KEY `algo_id_auto_index` (`algo_id`),
- CONSTRAINT `FK_model_algo_id` FOREIGN KEY (`algo_id`) REFERENCES `algorithm` (`algo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `model_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `model_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `tag` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `algo_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `create_time` int NOT NULL,
+ `file_path` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `precision` float NULL DEFAULT NULL,
+ `username` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ PRIMARY KEY (`model_id`) USING BTREE,
+ INDEX `algo_id`(`algo_id`) USING BTREE,
+ CONSTRAINT `model_ibfk_1` FOREIGN KEY (`algo_id`) REFERENCES `algorithm` (`algo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `workflow` (
- `workflow_id` CHAR(20) NOT NULL,
- `workflow_name` CHAR(10) NOT NULL,
- `status` CHAR(12) NOT NULL,
- `description` CHAR(50) NULL,
- `app_name` CHAR(10) NOT NULL,
- `app_id` CHAR(10) NOT NULL,
- `step` INT(11) NOT NULL,
- `period` INT(11) NOT NULL,
- `domain` CHAR(20) NOT NULL,
- `username` CHAR(40) NOT NULL,
- PRIMARY KEY (`workflow_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `workflow_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `workflow_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `create_time` int NOT NULL,
+ `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `app_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `app_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `step` int NULL DEFAULT NULL,
+ `period` int NULL DEFAULT NULL,
+ `domain` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ `username` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
+ PRIMARY KEY (`workflow_id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
CREATE TABLE IF NOT EXISTS `workflow_host` (
- `host_id` CHAR(32) NOT NULL,
- `workflow_id` CHAR(10) NULL,
- `host_name` CHAR(20) NULL,
- `host_ip` CHAR(16) NULL,
- PRIMARY KEY (`host_id`),
- KEY `workflow_id_auto_index` (`workflow_id`),
- CONSTRAINT `FK_workflow_workflow_id` FOREIGN KEY (`workflow_id`) REFERENCES `workflow` (`workflow_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC ;
+ `host_id` int NOT NULL,
+ `host_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `host_ip` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `workflow_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ PRIMARY KEY (`host_id`, `workflow_id`) USING BTREE,
+ INDEX `workflow_id`(`workflow_id`) USING BTREE,
+ CONSTRAINT `workflow_host_ibfk_1` FOREIGN KEY (`workflow_id`) REFERENCES `workflow` (`workflow_id`) ON DELETE CASCADE ON UPDATE RESTRICT
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
diff --git a/diana/database/dao/app_dao.py b/diana/database/dao/app_dao.py
index 653eb17..e5bce31 100644
--- a/diana/database/dao/app_dao.py
+++ b/diana/database/dao/app_dao.py
@@ -96,12 +96,12 @@ class AppDao(ElasticsearchProxy):
return SUCCEED, result
total_count = count_res[1]
- paginate = dict(page=data["page"], size=data["per_page"])
+ paginate = dict(page=int(data["page"]), size=int(data["per_page"]))
self._make_es_paginate_body(paginate, query_body)
res = self.query(index, query_body, ["app_id", "version", "app_name", "description"])
if res[0]:
LOGGER.debug("query app list succeed")
- result["total_page"] = (total_count + data["per_page"] - 1) / data["per_page"]
+ result["total_page"] = (total_count + int(data["per_page"]) - 1) / int(data["per_page"])
result["total_count"] = total_count
for item in res[1]['hits']['hits']:
result["app_list"].append(item['_source'])
--
Gitee

Binary file not shown.

BIN
aops-diana-v1.3.0.tar.gz Normal file

Binary file not shown.

View File

@ -1,13 +1,17 @@
Name: aops-diana
Version: v1.2.0
Release: 1
Version: v1.3.0
Release: 4
Summary: An intelligent abnormal detection framework of aops
License: MulanPSL2
URL: https://gitee.com/openeuler/%{name}
Source0: %{name}-%{version}.tar.gz
Patch0001: 0001-add-diana-sql-script.patch
Patch0002: 0002-fix-database-type-error.patch
BuildRequires: python3-setuptools
Requires: aops-vulcanus >= v1.2.0
Requires: aops-vulcanus >= v1.3.0
Requires: python3-requests python3-flask python3-flask-restful python3-marshmallow >= 3.13.0
Requires: python3-numpy python3-pandas python3-prometheus-api-client
Requires: python3-sqlalchemy python3-PyMySQL python3-Flask-APScheduler >= 1.11.0
@ -21,7 +25,7 @@ An intelligent abnormal detection framework of aops
%prep
%autosetup -n %{name}-%{version}
%autosetup -n %{name}-%{version} -p1
# build for aops-diana
@ -30,6 +34,8 @@ An intelligent abnormal detection framework of aops
# install for aops-diana
%py3_install
mkdir -p %{buildroot}/opt/aops/
cp -r database %{buildroot}/opt/aops/
%files
@ -42,9 +48,22 @@ An intelligent abnormal detection framework of aops
%attr(0755,root,root) /usr/lib/systemd/system/aops-diana.service
%{python3_sitelib}/aops_diana*.egg-info
%{python3_sitelib}/diana/*
%attr(0755, root, root) /opt/aops/database/*
%changelog
* Mon Sep 25 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.0-4
- fix database type error
* Thu Sep 21 2023 wenxin<shusheng.wen@outlook.com> - v1.3.0-3
- update spec requires
* Tue Sep 19 2023 wenxin<shusheng.wen@outlook.com> - v1.3.0-2
- add the sql script
* Mon Sep 11 2023 zhuyuncheng<zhuyuncheng@huawei.com> - v1.3.0-1
- update to v1.3.0
* Mon Apr 17 2023 gongzhengtang<gong_zhengtang@163.com> - v1.2.0-1
- update the structure of response body; update how to get session used to
- connect to the database