一个模块化的 eBPF 监控系统,带有 HTTP API 服务器,用于实时网络和系统事件监控。支持虚拟机和 Kubernetes 部署,并自动丰富元数据。
在整个 Kubernetes 集群中部署,并自动丰富节点元数据:
# 使用内置脚本快速部署
./scripts/deploy.sh all --registry your-registry.com
# 或者分步部署
make docker-build
make docker-push REGISTRY=your-registry.com
make k8s-deploy
📖 完整的 Kubernetes 指南 - 详细的设置和配置
在本地测试完整的 Kubernetes 部署:
# 完整自动化测试
make kind-full-test
# 或者分步进行:
make kind-cluster-create # 创建本地集群
make kind-deploy # 部署到 kind 集群
make kind-integration-test # 运行全面测试
要获取聚合器的详细 API 文档,请参阅仅在 Kubernetes 模式下可用的 API 聚合器文档
对于单服务器部署:
# 安装依赖项(Ubuntu/Debian)
sudo apt install -y golang-go clang libbpf-dev linux-headers-$(uname -r)
# 构建并运行
make build
sudo ./bin/ebpf-server
# 测试 API
curl http://localhost:8080/health
curl "http://localhost:8080/api/events?type=connection&limit=1
📚 交互式 API 文档 - 在浏览器中测试 API
Kubernetes 中的事件包括丰富的元数据:
{
"id": "abc123",
"type": "connection",
"k8s_node_name": "worker-node-1",
"k8s_pod_name": "ebpf-monitor-xyz",
"k8s_namespace": "ebpf-system",
...
}
Kubernetes 模式:分布式监控与集中式聚合
┌─────────────────────────────────────────────────────────┐
│ Kubernetes 集群 │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ 节点 1 │ │ 节点 2 │ │ 节点 N │ │
│ │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │ │
│ │ │ eBPF │ │ │ │ eBPF │ │ │ │ eBPF │ │ │
│ │ │ 代理 │ │ │ │ 代理 │ │ │ │ 代理 │ │ │
│ │ │+K8s 元数据│ │ │ │+K8s 元数据│ │ │ │+K8s 元数据│ │ │
│ │ └────┬────┘ │ │ └────┬────┘ │ │ └────┬────┘ │ │
│ └──────┼──────┘ └──────┼──────┘ └────────┼────────┘ │
│ │ │ │ │
│ └────────────────┼──────────────────┘ │
│ │ │
│ ┌─────▼─────┐ │
│ │ eBPF │ │
│ │ 聚合器│◄─── 统一 API │
│ │ │ │
│ └───────────┘ │
└─────────────────────────────────────────────────────────┘
VM 模式:基于接口的模块化监控系统
┌─────────────────────────────────────────────────────┐
│ eBPF 程序 │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 连接 │ │ 数据包丢失 │ │ 自定义 │ │
│ │ 监控 │ │ 监控 │ │ 监控 │ │
│ └──────┬──────┘ └──────┬──────┘ └─────────┬───┘ │
└─────────┼─────────────────┼──────────────────┼-─────┘
│ │ │
└─────────────────┼──────────────────┘
▼
┌─────────────────────────┐
│ 事件处理 │
│ (管理器 + 存储) │
└─────────────┬───────────┘
▼
┌─────────────────────────┐
│ HTTP API │
│ (/api/events) │
└─────────────────────────┘
/api/events 端点用于所有监控数据/api/programs 查看程序状态和指标GET /health - 系统健康和状态GET /api/events - 带过滤支持的事件查询GET /api/programs - 列出所有程序及其状态# 获取过去一小时的所有连接事件
curl "http://localhost:8080/api/events?type=connection&since=2023-01-01T00:00:00Z"
# 获取特定进程的事件
curl "http://localhost:8080/api/events?pid=1234&limit=50"
# Kubernetes:获取特定节点的事件
curl "http://localhost:8080/api/events?k8s_node_name=worker-1"
type: 事件类型过滤(例如,“connection”,“packet_drop”)pid: 进程 ID 过滤command: 命令名称过滤k8s_node_name, k8s_pod_name, k8s_namespace: Kubernetes 过滤since, until: RFC3339 时间戳过滤limit: 最大结果数(默认:100)# 开发构建,带调试日志
make build-dev && sudo ./bin/ebpf-server-dev
# 生成 API 文档
make docs
# 运行测试
make test
# 构建 eBPF 程序
make build-bpf
📚 完整的开发指南 - 详细的创建新 eBPF 监控程序的指南
├── cmd/ # 应用入口点
│ ├── server/ # eBPF 监控服务器
│ └── aggregator/ # Kubernetes 聚合器
├── internal/
│ ├── core/ # 核心接口和类型
│ ├── events/ # 事件系统(BaseEvent,流)
│ ├── programs/ # eBPF 程序实现
│ ├── storage/ # 事件存储和查询
│ ├── api/ # HTTP API 处理器
│ ├── kubernetes/ # Kubernetes 元数据集成
│ └── system/ # 系统初始化
├── bpf/ # eBPF C 程序和头文件
├── kubernetes/ # Kubernetes 清单
├── scripts/ # 部署和测试脚本
└── docs/ # 文档和 API 规范
📖 设置指南:docs/setup.md
MIT 许可证 - 详见 LICENSE 文件。