关于 siem-logging
面向安全团队的 SIEM 日志规划技能,涵盖平台选择、检测规则、日志架构、留存策略与告警调优,适用于威胁监控和合规审计。
主要功能
- 01比较 SIEM 平台
- 02设计日志聚合架构
- 03编写 SIGMA 和原生规则
- 04规划合规留存策略
- 05调优告警并降低噪声
适用场景
- 01为云端或本地系统选择 SIEM
- 02构建账户攻击检测规则
- 03规划审计日志留存
- 04减少告警误报
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ ancoleman/ ai-design-components --skill siem-logging安装后在 Claude Code 中输入/siem-logging确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
outputs.yamlexamples/architectures/elk-stack-docker-compose.ymlfluentd-kubernetes-daemonset.yamlwazuh-docker-compose.ymlexamples/detection-rules/brute-force-detection.yamlprivilege-escalation.yamlexamples/sigma-rules/brute-force-detection.ymldata-exfiltration.ymllateral-movement.ymlprivilege-escalation.ymlreferences/alert-tuning-strategies.mdcloud-native-logging.mdcost-optimization.mddetection-rules-guide.mdlog-retention-policies.mdplatform-comparison.mdscripts/cost-calculator.py详细介绍
SIEM 日志记录
用途
使用 SIEM 平台(Elastic SIEM、Microsoft Sentinel、Wazuh、Splunk)配置全面的安全日志基础设施,以检测威胁、调查事件并维护合规审计轨迹。本技能涵盖平台选择、日志聚合架构、检测规则开发(SIGMA 格式和平台专用格式)、告警调优,以及满足法规合规要求(GDPR、HIPAA、PCI DSS、SOC 2)的保留策略。
何时使用此技能
在以下情况下使用此技能:
- 在基础设施中实施集中式安全事件监控
- 编写用于检测身份验证失败、权限提升和数据外泄的威胁检测规则
- 为多云环境(AWS、Azure、GCP、Kubernetes)设计日志聚合方案
- 满足日志保留和审计轨迹方面的合规要求
- 调优安全告警,以减少误报和告警疲劳
- 计算高容量安全日志记录(TB/天级)的成本
- 将安全日志记录集成到事件响应工作流中
SIEM 平台选择
快速决策框架
根据以下因素选择 SIEM 平台:
预算考量:
- 预算不限 → Splunk Enterprise Security(企业级功能、经过验证的扩展能力)
- 预算适中(每年 $50k-$500k) → Microsoft Sentinel 或 Elastic SIEM(云原生、灵活)
- 预算有限(每年 <$50k) → Wazuh(免费、开源 XDR/SIEM)
基础设施背景:
- 大量使用 Azure → Microsoft Sentinel(原生集成、内置 SOAR)
- 大量使用 AWS → AWS Security Lake + OpenSearch(AWS 原生)
- 多云或本地部署 → Elastic SIEM 或 Wazuh(平台无关)
数据量:
- >1 TB/天 → Splunk 或 Elastic Cloud(经过大规模应用验证)
- 100 GB - 1 TB/天 → Microsoft Sentinel 或 Elastic SIEM
- <100 GB/天 → Wazuh 或 Sentinel 50 GB 层级
团队专业能力:
- 具备 Elasticsearch 使用经验 → Elastic SIEM(工具熟悉)
- 具备 Microsoft/Azure 专业知识 → Microsoft Sentinel(Azure 生态系统)
- 通才团队或资源有限 → Wazuh(学习曲线最平缓)
平台对比摘要
| 平台 | 成本 | 部署方式 | 最适合 |
|---|---|---|---|
| Elastic SIEM | $$$ | 云端/可自托管 | 多云、需要定制的场景、DevOps 团队 |
| Microsoft Sentinel | $$$ | 云端(Azure) | 大量使用 Azure 的组织、需要内置 SOAR 的场景、云优先环境 |
| Wazuh | 免费 | 可自托管 | 注重成本的组织、中小型企业、合规要求 |
| Splunk ES | $$$$$ | 云端/本地 | 大型企业、海量数据、预算不限 |
如需详细的功能对比,请参阅 references/platform-comparison.md。
检测规则
通用格式:SIGMA 规则
SIGMA 提供通用检测规则格式,可将规则编译为任意 SIEM 查询语言(Elastic EQL、Splunk SPL、Microsoft KQL)。
SIGMA 规则结构:
title: Multiple Failed Login Attempts from Single Source
id: 8a9e3c7f-4b2d-4e8a-9f1c-2d5e6f7a8b9c
status: stable
description: Detects potential brute force attacks (10+ failed logins in 10 minutes)
author: Security Team
date: 2025/12/03
references:
- https://attack.mitre.org/techniques/T1110/
tags:
- attack.credential_access
- attack.t1110
logsource:
category: authentication
product: linux
detection:
selection:
event.type: authentication
event.outcome: failure
timeframe: 10m
condition: selection | count() by source.ip > 10
level: high
将 SIGMA 编译为平台专用格式:
# Install SIGMA compiler
pip install sigma-cli
# Compile to Elastic EQL
sigmac -t es-eql sigma_rule.yml
# Compile to Splunk SPL
sigmac -t splunk sigma_rule.yml
# Compile to Microsoft KQL
sigmac -t kusto sigma_rule.yml
平台专用检测格式
Elastic EQL(事件查询语言):
sequence by user.name with maxspan=5m
[process where process.name == "powershell.exe" and
process.args : ("Invoke-WebRequest", "iwr", "wget")]
[process where process.parent.name == "powershell.exe"]
Microsoft Sentinel KQL:
SigninLogs
| where TimeGenerated > ago(1h)
| where ResultType != 0 // Failed login
| summarize FailedAttempts=count() by UserPrincipalName, IPAddress
| where FailedAttempts >= 10
Splunk SPL:
index=web_logs sourcetype=access_combined
| rex field=uri "(?<sql_keywords>union|select|insert|update|delete)"
| where isnotnull(sql_keywords)
| stats count by src_ip, uri
| where count > 5
如需完整的检测规则示例,请参阅:
examples/sigma-rules/- 通用 SIGMA 检测规则examples/elastic-eql/- Elastic 专用查询examples/microsoft-kql/- Microsoft Sentinel 查询examples/splunk-spl/- Splunk 搜索references/detection-rules-guide.md- 完整指南
日志聚合架构
集中式架构
所有日志使用单个 SIEM 实例。适用于以下情况:
- 单区域部署
- 中小型数据量(<1 TB/天)
- 单一云服务提供商或本地部署
- 安全团队规模有限(1-10 名分析师)
架构:
Application Servers → Log Shippers (Filebeat/Fluentd)
↓
Log Aggregator (Logstash/Fluentd)
↓
SIEM Platform (Elasticsearch/Splunk/Sentinel)
↓
Security Analysts (Dashboard/Alerts)
分布式架构(多区域)
在多个区域部署 SIEM 实例,并进行全局聚合。适用于:
- 多区域全球部署
- 数据驻留要求(GDPR、数据主权)
- 高数据量(每个区域每天 >1 TB)
- 区域分析的低延迟要求
架构:
Global SIEM (Correlation, Threat Intelligence)
↓
Regional SIEM (US-East) | Regional SIEM (EU-West) | Regional SIEM (APAC)
↓ ↓ ↓
Local Logs Local Logs Local Logs
云原生架构
利用托管云服务。适用于:
- 云优先型组织(AWS/Azure/GCP)
- 希望避免管理基础设施
- 日志量可变的弹性工作负载
- 预算足以承担云服务费用
AWS 示例:
CloudTrail + VPC Flow Logs + GuardDuty
↓
AWS Security Lake (S3 Data Lake)
↓
OpenSearch (Analysis) | Athena (SQL Queries)
部署示例请参阅:
examples/architectures/elk-stack-docker-compose.ymlexamples/architectures/fluentd-kubernetes-daemonset.yamlexamples/architectures/aws-security-lake-terraform/examples/architectures/wazuh-docker-compose.ymlreferences/cloud-native-logging.md
日志聚合工具
Fluentd(云原生): 面向 Kubernetes 和多云环境的 CNCF 项目。适用于容器化应用。
Logstash(Elastic Stack): 原生集成 Elasticsearch。适用于高级解析(grok 模式)和数据丰富。
完整配置示例请参阅 examples/logstash-pipelines/ 和 references/cloud-native-logging.md。
日志保留与合规
合规要求
| 框架 | 最短保留期限 | 热存储 | 温存储 | 冷存储 |
|---|---|---|---|---|
| GDPR | 30-90 天 | 7 天 | 30 天 | 60 天 |
| HIPAA | 6 年 | 30 天 | 180 天 | 6 年 |
| PCI DSS | 1 年 | 90 天 | 180 天 | 1 年 |
| SOC 2 | 1 年 | 30 天 | 90 天 | 1 年 |
存储分层策略
热层(SSD,实时):
- 最近 7-30 天
- 实时索引和快速查询
- 成本最高($0.10/GB/月)
温层(HDD,近期):
- 30-90 天
- 只读索引,偶尔搜索
- 成本适中($0.05/GB/月)
冷层(S3/Blob,归档):
- 90 天至保留期限上限
- 可搜索快照,极少查询
- 成本最低($0.01/GB/月)
成本优化示例:
500 GB/day log volume, 1-year retention
Hot (30 days): 15 TB @ $0.10/GB = $1,500/month
Warm (60 days): 30 TB @ $0.05/GB = $1,500/month
Cold (275 days): 137.5 TB @ $0.01/GB = $1,375/month
Total: $4,375/month = $52,500/year
vs. Hot-only: $18,250/month = $219,000/year
Savings: 76% ($166,500/year)
详细的保留策略和成本优化信息请参阅:
references/log-retention-policies.mdreferences/cost-optimization.mdscripts/cost-calculator.py
应记录的内容(安全事件)
关键事件(必须记录):
- 身份验证:登录尝试、MFA、密码更改、权限提升
- 授权:权限更改、角色修改、访问拒绝
- 数据访问:敏感数据库/文件访问、API 调用、导出
- 网络:连接、防火墙拒绝、VPN、DNS 查询
- 系统:服务更改、配置修改、软件安装
严重级别: 身份验证失败(3 次以上):高危警报 | 权限提升:严重警报 | 数据导出:高危警报 | 配置更改:中危(不触发警报)
警报调优与降噪
警报生命周期
- 创建检测规则 - 采用保守阈值,部署到生产环境
- 基线期(2-4 周) - 收集警报数据,标记真正例和假正例
- 调优阶段 - 添加白名单、调整阈值、优化关联规则
- 持续改进 - 每周审查指标,每月审查有效性
降噪技术
白名单(已知安全模式):
# Example: Allow scanner IPs
- rule_id: brute_force_detection
whitelist:
- source_ip: "10.0.0.100" # Security scanner
- user_agent: "Nagios" # Monitoring system
阈值调优:
# Before: Too sensitive (500 alerts/day, 5% true positive rate)
- rule: failed_login_attempts
threshold: 3 attempts in 5 minutes
# After: Tuned (50 alerts/day, 40% true positive rate)
- rule: failed_login_attempts
threshold: 10 attempts in 10 minutes
多事件关联:
# Instead of: Single event alert
- alert_on: "Failed authentication"
# Use: Correlated pattern
- alert_on:
- "Failed authentication (5+ times)"
- AND "From new IP address"
- AND "Successful authentication follows"
- WITHIN: 30 minutes
目标警报指标
| 指标 | 目标 |
|---|---|
| 每日警报总数 | <100 |
| 真正例率 | >30% |
| 平均调查时间 | <15 分钟 |
| 假正例率 | <50% |
| 每日严重警报数 | <10 |
全面的警报调优策略请参阅 references/alert-tuning-strategies.md。
快速入门
部署 Wazuh: git clone https://github.com/wazuh/wazuh-docker.git && cd wazuh-docker/single-node && docker-compose up -d(参见 examples/architectures/wazuh-docker-compose.yml)
创建 SIGMA 规则: SSH 暴力破解检测模板请参见 examples/sigma-rules/brute-force-detection.yml
Elastic Cloud: 在 cloud.elastic.co 注册,创建 Security 层级部署,并在端点上安装 Elastic Agent
与相关技能集成
observability 技能:
- 将安全日志路由到 SIEM,将性能日志路由到可观测性平台
- 共享日志聚合基础设施(Fluentd/Logstash)
- 分析目的不同(安全与性能)
incident-management 技能:
- SIEM 警报会触发事件响应工作流
- 与 PagerDuty、Opsgenie、ServiceNow 集成
- 针对严重安全事件自动创建事件
security-hardening 技能:
- SIEM 监控安全配置和合规性
- 检测相对于 CIS 基准的配置偏移
- 针对违反安全策略的情况发出警报
building-ci-pipelines 技能:
- 记录 CI/CD 安全事件(部署、机密访问)
- 将 GitHub Actions/GitLab CI 与 SIEM 集成
- 监控供应链安全
secret-management 技能:
- 审计所有机密访问操作
- 将 HashiCorp Vault/AWS Secrets Manager 日志发送到 SIEM
- 检测未经授权的机密访问尝试
参考文档
详细指南
references/platform-comparison.md- SIEM 平台功能综合对比references/detection-rules-guide.md- 检测规则格式(SIGMA、EQL、KQL、SPL)references/log-retention-policies.md- 合规要求和保留策略references/cloud-native-logging.md- AWS、Azure、GCP、Kubernetes 日志记录设置references/alert-tuning-strategies.md- 减少误报和优化警报references/cost-optimization.md- 存储分层和成本管理
实用示例
examples/sigma-rules/- 通用 SIGMA 检测规则(10 个以上示例)examples/elastic-eql/- Elastic 事件查询语言查询examples/microsoft-kql/- Microsoft Sentinel Kusto 查询examples/splunk-spl/- Splunk 搜索处理语言examples/architectures/- 完整部署示例(Docker、Kubernetes、Terraform)examples/logstash-pipelines/- Logstash 管道配置
实用脚本
scripts/sigma-to-elastic.sh- 将 SIGMA 规则转换为 Elastic EQLscripts/cost-calculator.py- 根据数据量和保留时长估算 SIEM 成本
官方文档
- Elastic SIEM: https://www.elastic.co/security
- Microsoft Sentinel: https://azure.microsoft.com/en-us/products/microsoft-sentinel
- Wazuh: https://wazuh.com/
- Splunk Enterprise Security: https://www.splunk.com/en_us/products/enterprise-security.html
- SIGMA 规则仓库: https://github.com/SigmaHQ/sigma
- MITRE ATT&CK 框架: https://attack.mitre.org/