hostwatch/README.md

38 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# hostwatch — 日志监控与分析 + 主机指标模块
FOMS 平台拆出的独立模块之一。松耦合:表 `node_id` 仅存字符串 ID不建外键
采集由 Agent 完成,管理中心负责入库、规则匹配、告警、归类分析。
## 职责
| 功能 | 表 | 说明 |
|---|---|---|
| 节点日志 | `hostwatch_logs` | 日志采集,含 category 归类字段,原 `node_logs` |
| 节点指标 | `hostwatch_metrics` | CPU/内存/磁盘/负载/网络,原 `node_metrics` |
| 监控规则 | `hostwatch_rules` | 关键词/正则 + 级别 + 频次阈值 + 通知 |
| 告警事件 | `hostwatch_events` | 命中事件,含状态/通知标记 |
## 端点
| 端点 | 说明 |
|---|---|
| `/hostwatch/api/agent_report_metrics.dspy` | Agent 上报指标 |
| `/hostwatch/api/agent_push_logs.dspy` | Agent 推送日志(入库+归类+规则匹配) |
| `/hostwatch/api/node_metrics_history.dspy` | 指标历史(图表) |
| `/hostwatch/api/node_logs.dspy` | 节点日志查询 |
| `/hostwatch/api/analyze_logs.dspy` | 日志分析(级别/归类聚合 + Top 错误) |
| `/hostwatch/api/acknowledge_event.dspy` | 确认/关闭告警 |
## 日志分析
- 归类关键词规则database/network/disk/system/security/application/general
- 告警:规则匹配命中 → 窗口内累计频次 → 超阈值生成 open 事件
- 分析:按级别/归类聚合统计 + Top 错误信息
## 加载
```python
from hostwatch.init import load_hostwatch
load_hostwatch()
```