添加 READM.txt
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
/opt/alert_dashboard/
|
||||||
|
├── docker-compose.yml # 容器编排主文件
|
||||||
|
├── nginx/
|
||||||
|
│ └── default.conf # Nginx站点配置
|
||||||
|
├── www/
|
||||||
|
│ ├── api/
|
||||||
|
│ │ └── index.php # 你提供的PHP接口文件
|
||||||
|
│ └── dashboard.html # H5看板页面
|
||||||
|
├── python_crawler/
|
||||||
|
│ └── mail_crawler.py # 邮件抓取脚本
|
||||||
|
└── mysql_data/ # MySQL持久化数据目录(自动生成)
|
||||||
|
|
||||||
|
#Nginx 配置 /opt/alert_dashboard/nginx/default.conf
|
||||||
|
mkdir -p /opt/alert_dashboard/{nginx,www/api,python_crawler,mysql_data}
|
||||||
|
cd /opt/alert_dashboard
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
|
||||||
|
# 前端静态页面
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/;
|
||||||
|
}
|
||||||
|
|
||||||
|
# PHP告警接口
|
||||||
|
location /api {
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/api/index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#数据库设计
|
||||||
|
CREATE DATABASE alert_mail_stat DEFAULT CHARACTER SET utf8mb4;
|
||||||
|
USE alert_mail_stat;
|
||||||
|
|
||||||
|
-- 告警事件主表(每条邮件=一条记录)
|
||||||
|
CREATE TABLE alert_log (
|
||||||
|
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '自增ID',
|
||||||
|
mail_uid VARCHAR(100) NOT NULL COMMENT '邮件唯一ID,去重防止重复采集',
|
||||||
|
alert_type TINYINT NOT NULL COMMENT '1触发firing 2恢复resolved',
|
||||||
|
alert_name VARCHAR(200) NOT NULL COMMENT '告警名称(Port_Down/NetworkInHigh)',
|
||||||
|
instance VARCHAR(200) NOT NULL COMMENT '实例地址IP:端口',
|
||||||
|
severity VARCHAR(50) NOT NULL COMMENT '级别critical/warning',
|
||||||
|
starts_at DATETIME NULL COMMENT '告警开始UTC转北京时间',
|
||||||
|
ends_at DATETIME NULL COMMENT '告警恢复时间',
|
||||||
|
content TEXT COMMENT '邮件完整正文',
|
||||||
|
receive_time DATETIME NOT NULL COMMENT '邮件接收入库时间',
|
||||||
|
UNIQUE KEY uk_mail_uid(mail_uid),
|
||||||
|
INDEX idx_day(receive_time),
|
||||||
|
INDEX idx_alert_name(alert_name),
|
||||||
|
INDEX idx_instance(instance)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
#后端接口
|
||||||
|
今日汇总:http://xxx/alert_api/index.php?act=day_total
|
||||||
|
TOP10 告警:http://xxx/alert_api/index.php?act=top_alert
|
||||||
|
告警明细:http://xxx/alert_api/index.php?act=log_list
|
||||||
|
|
||||||
|
pip3 install pymysql 依赖
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user