在 Splunk 上过滤访问日志
Filter access logs on Splunk
SplunkForwarder 用于向 Splunk 提供 Apache 的访问日志(或者被 DevOps 告知)。据我所知,不可能根据给定的正则表达式过滤掉日志——我试图解决的 ISSUE。正在考虑在 Apache 上添加一个触发器,如果请求的 URL 模式在白名单中,它将拦截所有请求并向 Splunk 发送消息(发现 Splunk HTTP 事件收集器 - 以前从未使用过 - 闻起来像一部分的解决方案)。
试图找到如何使用 mod_actions 模块的正确示例。不幸的是,没有找到对我有用的东西。 Apache 的文档毫无用处。不确定 mod_actions 是否是我唯一的选择。
请告诉我如何为每个请求执行 py/sh/pl 或任何其他脚本?很可能,DevOps 不允许我向 Apache 添加任何奇异的(非标准)模块。
非常感谢。
完全可以根据正则表达式过滤日志。您将需要一个索引器上的应用程序,以根据通用转发器上 inputs.conf 中定义的源类型进行过滤。
下面提供的 props.conf/transforms.conf 组合将仅保留包含字符串 Error 或 Warning 的日志行,而所有其他消息将被发送到 nullqueue(已删除)。
$SPLUNK_HOME$/etc/apps/your_app/local/props.conf
$SPLUNK_HOME$/etc/apps/your_app/local/transforms.conf
props.conf
[your_sourcetype]
TRANSFORMS-set = setnull, setparsing
transforms.conf
# This sends all events to be ignored
[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue
# this says ignore all events, except the ones containing ERROR
[setparsing]
REGEX = Error|Warning
DEST_KEY = queue
FORMAT = indexQueue
[your_sourcetype1]
TRANSFORMS-set = setnull, setparsing
[your_souretype2]
TRANSFORMS-set = setnull, setparsing
SplunkForwarder 用于向 Splunk 提供 Apache 的访问日志(或者被 DevOps 告知)。据我所知,不可能根据给定的正则表达式过滤掉日志——我试图解决的 ISSUE。正在考虑在 Apache 上添加一个触发器,如果请求的 URL 模式在白名单中,它将拦截所有请求并向 Splunk 发送消息(发现 Splunk HTTP 事件收集器 - 以前从未使用过 - 闻起来像一部分的解决方案)。 试图找到如何使用 mod_actions 模块的正确示例。不幸的是,没有找到对我有用的东西。 Apache 的文档毫无用处。不确定 mod_actions 是否是我唯一的选择。 请告诉我如何为每个请求执行 py/sh/pl 或任何其他脚本?很可能,DevOps 不允许我向 Apache 添加任何奇异的(非标准)模块。 非常感谢。
完全可以根据正则表达式过滤日志。您将需要一个索引器上的应用程序,以根据通用转发器上 inputs.conf 中定义的源类型进行过滤。
下面提供的props.conf/transforms.conf 组合将仅保留包含字符串 Error 或 Warning 的日志行,而所有其他消息将被发送到 nullqueue(已删除)。
$SPLUNK_HOME$/etc/apps/your_app/local/props.conf $SPLUNK_HOME$/etc/apps/your_app/local/transforms.conf
props.conf
[your_sourcetype]
TRANSFORMS-set = setnull, setparsing
transforms.conf
# This sends all events to be ignored
[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue
# this says ignore all events, except the ones containing ERROR
[setparsing]
REGEX = Error|Warning
DEST_KEY = queue
FORMAT = indexQueue
[your_sourcetype1]
TRANSFORMS-set = setnull, setparsing
[your_souretype2]
TRANSFORMS-set = setnull, setparsing