mrezwanulbari/Splunk-SC4S-High-Performance-Log-Ingestion-Pipeline

GitHub: mrezwanulbari/Splunk-SC4S-High-Performance-Log-Ingestion-Pipeline

该项目提供 Splunk Connect for Syslog 的完整部署配置方案,帮助企业高性能地将多源 syslog 日志统一接入 Splunk 平台。

Stars: 1 | Forks: 0

# Splunk Connect for Syslog (SC4S) — 高性能日志接入管道与 Splunk SC4S ![Splunk](https://img.shields.io/badge/Splunk-000000?style=for-the-badge&logo=splunk&logoColor=white) ![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white) ![License](https://img.shields.io/badge/License-MIT-green.svg) ## 功能: - 使用 Splunk SC4S 进行**优化的日志解析**和处理 - 面向不断增长的日志量的**可扩展架构** ## 性能基准测试: - **日志接入速率**:每分钟 100 万条日志 - **延迟**:日志处理时间少于 2 秒 ## 📋 目录 - [概述](#overview) - [架构](#architecture) - [仓库结构](#repository-structure) - [快速开始](#quick-start) - [日志源接入](#source-onboarding) - [自定义日志路径](#custom-log-paths) - [性能调优](#performance-tuning) - [高可用](#high-availability) - [监控](#monitoring) - [故障排除](#troubleshooting) - [贡献](#contributing) ## 概述 **SC4S (Splunk Connect for Syslog)** 是一个容器化的 syslog-ng 解决方案,可为 Splunk 提供可靠、高性能的 syslog 收集服务。它会自动解析、分类 syslog 数据,并将其路由到正确的 Splunk index 和 sourcetype。 ### 为什么选择 SC4S? | 功能 | 优势 | |---|---| | **自动分类** | 自动识别 200 多种 syslog 源 | | **容器化** | 使用 Docker/Podman 部署,占用资源极少 | | **HEC 集成** | 通过 HTTP Event Collector 发送数据以确保可靠性 | | **合规性** | 确保为监管框架提供一致的日志收集 | | **可扩展性** | 每个实例可处理 50,000+ EPS | ### 支持的来源(部分列表) | 类别 | 来源 | |---|---| | **防火墙** | Palo Alto, Cisco ASA/FTD, Fortinet, Check Point, Juniper SRX | | **网络** | Cisco IOS/NX-OS, Arista, F5 BIG-IP, Aruba, Brocade | | **安全** | CrowdStrike, Carbon Black, Symantec, McAfee, Trend Micro | | **身份认证** | Cisco ISE, Aruba ClearPass, FreeRADIUS | | **基础设施** | VMware ESXi/vCenter, NetApp, Nutanix, Dell iDRAC | | **Linux/Unix** | syslog, auditd, journald, authlog | ## 架构 ### 单实例部署 ``` ┌─────────────────────────────────────────────────────────┐ │ Network Sources │ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ │ FW │ │Switch│ │ IDS │ │ WAF │ │ ESXi │ │ │ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ │ └─────┼────────┼────────┼────────┼────────┼───────────────┘ │UDP/514 │TCP/514 │TCP/601 │TCP/6514│UDP/514 │ │ │ │(TLS) │ ┌─────▼────────▼────────▼────────▼────────▼───────────────┐ │ SC4S Container │ │ ┌─────────────────────────────────────────────────┐ │ │ │ syslog-ng engine │ │ │ │ ┌──────────┐ ┌───────────┐ ┌─────────────┐ │ │ │ │ │ Parser │ │ Classifier│ │ Router │ │ │ │ │ │ Engine │ │ (Filter) │ │ (Index Map) │ │ │ │ │ └──────────┘ └───────────┘ └──────┬──────┘ │ │ │ └────────────────────────────────────┼────────────┘ │ │ │ HEC │ └───────────────────────────────────────┼─────────────────┘ │ ┌───────────────────────────────────────▼─────────────────┐ │ Splunk Indexer Cluster │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ IDX-1 │ │ IDX-2 │ │ IDX-3 │ │ │ └─────────┘ └─────────┘ └─────────┘ │ └─────────────────────────────────────────────────────────┘ ``` ### 多实例 HA 部署 ``` ┌──────────────┐ │ Load Balancer│ │ (F5/HAProxy) │ └───┬──────┬───┘ │ │ ┌─────────▼─┐ ┌─▼─────────┐ │ SC4S-1 │ │ SC4S-2 │ │ (Active) │ │ (Active) │ └─────┬──────┘ └──────┬─────┘ │ │ └───────┬────────┘ │ HEC ┌───────▼────────┐ │ Splunk HEC │ │ Endpoint(s) │ └────────────────┘ ``` ## 仓库结构 ``` splunk-sc4s/ ├── README.md ├── docker-compose.yml ├── .env.example ├── configs/ │ ├── env_file # SC4S environment variables │ ├── context/ │ │ ├── splunk_metadata.csv # Source-to-index/sourcetype mapping │ │ ├── vendor_product_by_source.csv # Custom source identification │ │ └── vendor_product_by_source.conf # syslog-ng filter overrides │ └── local/ │ ├── context/ │ │ └── splunk_metadata.csv # Local overrides │ └── config/ │ └── addons/ # Custom log path addons ├── sources/ │ ├── palo-alto/ # Palo Alto Networks onboarding │ │ ├── README.md │ │ └── onboarding-guide.md │ ├── cisco-asa/ # Cisco ASA/FTD onboarding │ │ ├── README.md │ │ └── onboarding-guide.md │ ├── fortinet/ # Fortinet FortiGate onboarding │ │ ├── README.md │ │ └── onboarding-guide.md │ ├── cisco-ios/ # Cisco IOS/NX-OS onboarding │ │ ├── README.md │ │ └── onboarding-guide.md │ ├── linux-syslog/ # Linux syslog onboarding │ │ ├── README.md │ │ └── onboarding-guide.md │ └── vmware/ # VMware ESXi/vCenter onboarding │ ├── README.md │ └── onboarding-guide.md ├── custom-parsers/ │ ├── README.md │ ├── custom_app_parser.conf # Example custom parser │ └── custom_filter_template.conf # Filter template ├── scripts/ │ ├── sc4s_health_check.sh # Container health monitoring │ ├── test_syslog_sources.sh # Test syslog connectivity │ └── hec_token_setup.sh # Automate HEC token creation ├── monitoring/ │ ├── sc4s_dashboard.xml # SC4S monitoring dashboard │ └── sc4s_alerts.conf # Alert definitions └── docs/ ├── deployment-guide.md # Full deployment walkthrough ├── source-onboarding-playbook.md # Step-by-step onboarding process ├── performance-tuning.md # Tuning for high EPS ├── tls-configuration.md # TLS/SSL setup guide └── troubleshooting.md # Common issues and solutions ``` ## 快速开始 ### 前置条件 - Docker Engine 20.10+ 或 Podman 3.0+ - 启用了 HEC 的 Splunk Enterprise - 从 SC4S 主机到 Splunk HEC endpoint 的网络访问权限(端口 8088) - 已配置为发送到 SC4S 主机的 syslog 源 ### 第 1 步:克隆并配置 ``` git clone https://github.com/mrezwanulbari/splunk-sc4s.git cd splunk-sc4s # 复制环境模板 cp .env.example .env # 使用您的 Splunk HEC 详情进行编辑 vi .env ``` ### 第 2 步:设置环境变量 ``` # .env 文件 SC4S_DEST_SPLUNK_HEC_DEFAULT_URL=https://splunk-hec.company.com:8088 SC4S_DEST_SPLUNK_HEC_DEFAULT_TOKEN=your-hec-token-here SC4S_DEST_SPLUNK_HEC_DEFAULT_TLS_VERIFY=no ``` ### 第 3 步:部署 SC4S ``` # 使用 Docker Compose docker-compose up -d # 验证 SC4S 是否正在运行 docker logs sc4s # 测试连通性 echo "<134>1 2024-01-15T10:30:00Z testhost testapp - - - Test message" | nc -u localhost 514 ``` ## 日志源接入 ### 接入工作流 ``` 1. Identify Source → 2. Check SC4S Support → 3. Configure Source ↓ ↓ 4. Update splunk_metadata.csv → 5. Create Splunk Index → 6. Validate Data ``` ### splunk_metadata.csv — Index 路由 ``` # 模板:key,metadata_field,metadata_value # 将 Palo Alto 流量日志路由到 firewall index palo_alto_traffic,index,idx_firewall palo_alto_threat,index,idx_firewall palo_alto_system,index,idx_firewall # 将 Cisco ASA 路由到 network security index cisco_asa,index,idx_network_security # 将 Linux syslog 路由到 OS index nix_syslog,index,idx_os_linux # 将 VMware 路由到 infrastructure index vmware_esx,index,idx_infrastructure vmware_vcenter,index,idx_infrastructure ``` ## 自定义日志路径 对于 SC4S 原生不支持的源,请创建自定义日志路径: ``` # custom-parsers/custom_app_parser.conf # 用于内部应用程序日志的 Custom parser filter f_custom_myapp { program("myapp") or match("MYAPP" value("MESSAGE")); }; log { source(s_DEFAULT); filter(f_custom_myapp); rewrite { set("custom_app" value(".splunk.sourcetype")); set("idx_custom" value(".splunk.index")); set("myapp" value(".splunk.source")); }; destination(d_hec); flags(flow-control, final); }; ``` ## 性能调优 | 参数 | 默认值 | 建议值(高 EPS) | 描述 | |---|---|---|---| | `SC4S_SOURCE_LISTEN_UDP_SOCKETS` | 1 | 4 | UDP 监听线程 | | `SC4S_DEST_SPLUNK_HEC_WORKERS` | 10 | 20 | HEC 连接 worker | | `SC4S_DEST_SPLUNK_HEC_MAX_BATCH_SIZE` | 500 | 1000 | 每个 HEC 批次的 event 数 | | Docker `--cpus` | 无限制 | 4 | CPU 分配 | | Docker `--memory` | 无限制 | 8g | 内存分配 | ### 基准测试结果 | 配置 | EPS 容量 | 备注 | |---|---|---| | 默认(1 CPU, 2GB) | ~5,000 EPS | 适用于小型环境 | | 调优(4 CPU, 8GB) | ~50,000 EPS | 生产环境推荐 | | 多实例(2倍调优) | ~100,000 EPS | 位于负载均衡器之后 | ## 故障排除 | 问题 | 诊断 | 解决方案 | |---|---|---| | Splunk 中无数据 | 检查 HEC 连接性 | `curl -k https://splunk:8088/services/collector/health` | | sourcetype 错误 | 源未被分类 | 在 `vendor_product_by_source.csv` 中添加条目 | | 数据进入默认 index | 缺少 index 映射 | 更新 `splunk_metadata.csv` | | 容器 CPU 占用高 | EPS 超出容量 | 扩容或按照性能调优进行调整 | | TLS 握手失败 | 证书不匹配 | 验证证书链和 CA bundle | ## 许可证 本项目基于 MIT 许可证授权。
标签:Docker, Syslog, 安全防御评估, 数据管道, 日志收集, 版权保护, 请求拦截, 软件工程, 运维