Wazuh 4.x 远程 Syslog 输出迁移到 5.x Dashboard 通知:Webhook 通道与 Alerting 监控的完整实战指南
【免费下载链接】wazuhWazuh - The Open Source Security Platform. Unified XDR and SIEM protection for endpoints and cloud workloads.项目地址: https://gitcode.com/GitHub_Trending/wa/wazuh
本指南讲解如何将 Wazuh 4.x 时代通过管理器ossec.conf中<syslog_output>配置块、由csyslogd守护进程执行的远程 Syslog 告警转发能力,迁移到 Wazuh 5.0 基于 Dashboard 的Notifications(通知)与Alerting(告警)插件的 Webhook 体系。阅读本文后,你将掌握 4.x 与 5.x 的配置映射方法、Custom Webhook 通知通道的创建、告警监控(Monitor)、触发器(Trigger)与动作(Action)的完整配置流程,并能用 Mustache 模板手工重建 JSON、CEF 或 Splunk 风格的转发负载。
迁移背景:后端 Syslog 转发能力的移除
在 Wazuh 4.x 中,将告警转发到远程日志服务器(如 SIEM、日志收集器)是通过管理器配置文件ossec.conf中的<syslog_output>配置块实现的,由管理器内部守护进程csyslogd负责实际的数据传输。运维人员需要在 XML 配置中显式声明目标服务器、端口、日志级别、规则组、规则 ID 以及输出格式。
从 Wazuh 5.0 开始,这些遗留的后端 Syslog 转发能力已从管理器中移除。仓库 发布说明 的 Breaking changes 部分明确列出:wazuh-csyslogd、wazuh-integratord、wazuh-reportd等已废弃管理器守护进程不再随发行版提供,且 5.x 不支持从 4.x 就地升级,必须全新安装并执行文档化的迁移流程。告警转发逻辑现在必须直接在 Wazuh Dashboard 中,通过Notifications与Alerting两个插件以 Webhook 形式配置。
注意:不存在自动升级工具来迁移你现有的 Wazuh 4.x
<syslog_output>配置。你必须手动在 Wazuh Dashboard 中重建数据过滤与转发逻辑。请使用下面的映射表来确定ossec.conf中每个元素对应 Wazuh 5.x 的哪个功能。
配置映射(4.x → 5.x)
下表将 Wazuh 4.xossec.conf中的每个元素映射到 Wazuh 5.x Dashboard 中对应的功能。条目使用section.element形式表示——例如syslog_output.server指ossec.conf中的<syslog_output><server>。
完整 XML 上下文请参见下文 Wazuh 4.x ossec.conf 参考。
Syslog 输出映射
4.xossec.conf | 5.x Dashboard | 指南 |
|---|---|---|
syslog_output.server | Notifications > Channels > Custom Webhook(目标主机) | 步骤 1 |
syslog_output.port | Notifications > Channels > Custom Webhook(目标端口) | 步骤 1 |
syslog_output.format | Alerting > Monitor > Action > Message(Mustache 模板) | 步骤 2.2 |
<syslog_output>filter | Alerting > Monitor > Query(数据过滤器) | 步骤 2.1 |
syslog_output.level | Alerting > Monitor > Trigger / 数据阈值过滤 | 步骤 2.2 |
syslog_output.group | Alerting > Monitor > Query / 数据过滤(wazuh.rule.tags) | 步骤 2.1 |
syslog_output.rule_id | Alerting > Monitor > Query / 数据过滤(wazuh.rule.id) | 步骤 2.1 |
选项范围说明:
protocol不是 Wazuh 4.xossec.conf中<syslog_output>的有效选项(文档化选项为server、port、level、group、rule_id、location、use_fqdn和format)。
Wazuh 4.x 协议说明:在 Wazuh 4.x 中,
syslog_output转发使用 Syslog 传输(默认 UDP,端口514)。在 Wazuh 5.x 中,Notifications 使用 HTTP/HTTPS POST Webhook 进行出站路由。目标端点必须支持 HTTP Webhook 摄取,否则你必须在接收端部署一个 Webhook 到 Syslog 的转换层。
输出格式说明:在 Wazuh 4.x 中,
<format>标签会自动将数据布局转换为预定义格式(json、cef或splunk)。在 Wazuh 5.x 中,Notifications 插件不包含这些预配置的编码格式。要迁移特定格式(如 ArcSight CEF、Splunk 键值对或自定义 JSON 负载),必须在 Action 配置阶段,使用 Mustache 语法变量在 Message 文本块中手动设计结构。
Wazuh 4.x ossec.conf 参考
以下是你可能已在ossec.conf中的典型 Wazuh 4.x 配置块,可作为迁移步骤中的参考基准。
端口上下文:在这个遗留的 4.x 示例中,端口
514是标准 Syslog 传输端口(UDP/TCP)。在 Wazuh 5.x 的 Webhook 路由中,请使用接收端暴露的 HTTP/HTTPS 端口(例如10515)。
<syslog_output> <server>192.168.1.50</server> <port>514</port> <format>json</format> <level>10</level> <group>authentication_failed,</group> </syslog_output>迁移步骤
前提条件
开始迁移前,请确保你具备:
- 已完整部署 Wazuh 5.0 或更高版本(indexer、manager、dashboard)。
- 以管理员身份访问 Wazuh Dashboard。
- 已准备好接收 Webhook 流量的目标端点 URL 和端口。
1. 创建 Custom Webhook 通知通道
与在 XML 块中直接定义原始服务器端点不同,在 5.x 中,目标端点现在以可复用的通知通道形式在 Dashboard UI 中管理。
- 打开 Wazuh Dashboard,进入Notifications插件。
- 进入Channels,点击Create channel。
- 为通道输入Name(例如
remote-syslog-webhook-channel)。 - (可选)提供用于说明该通道用途的Description。
- 在Configurations下,将Channel type选择为Custom webhook。
- 将Method设置为
POST。 - 在Define endpoints by下选择Webhook URL,输入与你遗留
syslog_output.server配置对应的端点地址(例如http://192.168.1.50:10515)。 这里使用你的 Webhook 端点的 HTTP/HTTPS 监听端口(例如10515),而不是遗留的 Syslog 传输端口514。如果目标只接受 Syslog(UDP/TCP 514),请在其前置一个 Webhook 到 Syslog 的桥接器,并将此 URL 指向该桥接的 HTTP 端点。 - (可选)点击Send test message验证网络连通性。
- 点击Create保存通道。
Custom Webhook 通道类型在 5.x 中还支持PUT、POST或PATCH方法、自定义 URL 与查询参数,以及自定义请求头(如Authorization、Content-Type),这为兼容各类接收端 API 提供了比 4.x 更灵活的出站控制能力。
2. 使用 Alerts 和 Monitors 重建数据过滤器
在 Wazuh 4.x 中,你使用<syslog_output>块配合<level>、<group>、<rule_id>等标签来决定转发哪些事件。在 Wazuh 5.0 中,Alerting 插件会周期性地直接对你选定的索引执行查询。
2.1 创建监控
- 在 Wazuh Dashboard 中进入Alerting插件,选择Monitors。
- 点击Create monitor。
- 配置监控:
- Monitor name:输入名称(例如
Syslog-Forwarding-Monitor)。 - Monitor type:根据你的转发行为选择Per query monitor或Per document monitor。
- Indexes:当你的过滤器依赖
wazuh.rule.*字段(例如wazuh.rule.level、wazuh.rule.tags或wazuh.rule.id)时,使用wazuh-findings-v5*。
- Monitor name:输入名称(例如
- 在Query / Data filter下,将旧的 XML 规则转换为 Dashboard 过滤条件。 例如,要复刻遗留的
<group>过滤器,添加一个wazuh.rule.tags包含预期值的条件。
字段演进提示:5.x 中检测结果被索引到
wazuh-findings-v5*索引(按类别拆分,如wazuh-findings-v5-system-activity*、wazuh-findings-v5-security*等)。4.x 的整型规则 ID 没有 1:1 对应物,5.x 的规则身份由wazuh.rule.title(可读字符串)与wazuh.rule.id(UUID,不再是数字)表达;同时wazuh.rule.level也从 0–16 的整数变为informational、low、medium、high、critical等分类值,迁移时需按组织路由需求重新校准阈值。
2.2 配置触发器与动作
触发器(Triggers)充当阈值选择器(类似遗留<level>的意图),而动作(Actions)定义出站负载的格式。
- 添加一个触发器并设置其条件。
- 配置触发器,使其在你的查询匹配到事件时激活,并为
wazuh.rule.level中期望的关键字添加严重级别过滤器(例如low、medium、high或critical)。如果使用Per document monitor,请使用文档级触发器条件。 - 在Actions下,点击Add notification并配置:
- Action name:提供一个标签(例如
Send-Syslog-Payload)。 - Channel:选择在 步骤 1 中创建的 Custom Webhook 通道。
- Message:将默认的 monitor/trigger 文本替换为基于 finding 的负载。使用来自
ctx.results的 Mustache 模板将告警字段映射到目标 JSON 结构。例如:
- Action name:提供一个标签(例如
{ "alert_id": "{{ctx.results.0.hits.hits.0._id}}", "rule_id": "{{ctx.results.0.hits.hits.0._source.wazuh.rule.id}}", "rule_title": "{{ctx.results.0.hits.hits.0._source.wazuh.rule.title}}", "severity_level": "{{ctx.results.0.hits.hits.0._source.wazuh.rule.level}}", "agent_name": "{{ctx.results.0.hits.hits.0._source.wazuh.agent.name}}", "event_dataset": "{{ctx.results.0.hits.hits.0._source.event.dataset}}" }- 点击Create激活监控管道。
格式重建要点:4.x 的
<format>json|cef|splunk</format>在 5.x 中没有自动等价物。上例展示的是 JSON 负载的手工重建;若目标端需要 ArcSight CEF 或 Splunk 键值对,你需要在 Message 中按对应规范拼装字段与转义字符,同时注意通道的Content-Type请求头要与负载类型一致。
2.3 测试转发器
- 在被监控端点上生成一个符合你过滤条件的事件。
- 在Alerting的Alerts历史中验证匹配的活动是否出现。
- 确认你的摄取端点收到了带有预期元数据的 HTTP POST 负载。
完整示例:复刻一个遗留的 syslog 转发过滤器
示例:复刻遗留的 syslog 转发过滤器
如果你的 Wazuh 4.xossec.conf包含:
<syslog_output> <server>192.168.1.50</server> <port>514</port> <level>10</level> <group>authentication_failed,</group> </syslog_output>你可以通过以下 Dashboard 工作流复刻此行为:
Monitor 设置:
- Type:Per query monitor
- Index pattern:
wazuh-findings-v5* - Data filter:
wazuh.rule.tags包含authentication_failed
Trigger 设置:
- Condition:当查询返回至少一条匹配文档时触发
- Data threshold filter:
wazuh.rule.level属于informational、low、medium、high或critical之一(根据你环境中的严重级别值调整)
Action 设置:
- Channel:你的 Custom Webhook 端点通道
- Message payload:
{ "alert_id": "{{ctx.results.0.hits.hits.0._id}}", "rule_description": "{{ctx.results.0.hits.hits.0._source.wazuh.rule.title}}", "severity_level": "{{ctx.results.0.hits.hits.0._source.wazuh.rule.level}}", "agent_host": "{{ctx.results.0.hits.hits.0._source.wazuh.agent.name}}" }迁移要点总结
- 无自动迁移工具:
<syslog_output>到 5.x Dashboard 的迁移必须手动完成,且与 5.x 整体迁移一致——发布说明明确 5.x 不提供 4.x 就地升级路径。 - 传输协议变化:出站从 UDP/TCP
514的 Syslog 变为 HTTP/HTTPS POST Webhook,需确保接收端支持 HTTP 摄取,或部署 Webhook 到 Syslog 转换层。 - 过滤器语义变化:
<group>映射到wazuh.rule.tags,<rule_id>映射到wazuh.rule.id(5.x 为 UUID),<level>的整数阈值需要映射为 5.x 的分类严重级别。 - 格式需手工重建:4.x 的
json/cef/splunk预定义格式在 5.x 中通过 Mustache 模板在 Action 的 Message 中手工构造,可利用ctx.results、ctx.monitor、ctx.alerts等监控上下文变量动态取值。
完成以上通道与监控的创建和测试后,你的 Wazuh 5.x 环境即可通过 Dashboard 通知体系,以 Webhook 方式将告警转发到原本由csyslogd负责的远程日志接收端。
【免费下载链接】wazuhWazuh - The Open Source Security Platform. Unified XDR and SIEM protection for endpoints and cloud workloads.项目地址: https://gitcode.com/GitHub_Trending/wa/wazuh
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考