简体   繁体   English

在 Splunk 上过滤访问日志

[英]Filter access logs on Splunk

SplunkForwarder is used in order to provide the Apache's access log to Splunk (or was told by DevOps so). SplunkForwarder 用于向 Splunk 提供 Apache 的访问日志(或由 DevOps 告知)。 AFAIK it's not possible to filter out logs based on given regEx -- the ISSUE that I'm trying to solve.据我所知这是不可能过滤掉根据给定的正则表达式的日志-我正在试图解决的问题 Was thinking to add a trigger on Apache that will intercept all requests and send a message to Splunk if the URL pattern of the request is in the whitelist (have found Splunk HTTP Event Collector - never used before - smells like a part of the solution).正在考虑在 Apache 上添加一个触发器,如果​​请求的 URL 模式在白名单中,它将拦截所有请求并向 Splunk 发送消息(发现 Splunk HTTP 事件收集器 - 以前从未使用过 - 闻起来像解决方案的一部分) . Tried to find a proper example of how to use mod_actions module.试图找到如何使用 mod_actions 模块的正确示例。 Unfortunately, didn't find anything that works for me.不幸的是,没有找到任何对我有用的东西。 The Apache's documentation is useless. Apache 的文档没用。 Not sure whether mod_actions is the only option I have.不确定 mod_actions 是否是我唯一的选择。 Pls, could you tell me how can I execute py/sh/pl or any other script for each request?请告诉我如何为每个请求执行 py/sh/pl 或任何其他脚本? Likely, DevOps won't allow me to add any exotic (non-standard) module to Apache.很可能,DevOps 不允许我向 Apache 添加任何外来(非标准)模块。 Thanks a lot.非常感谢。

It's totally possible to filter logs based on regex.完全可以基于正则表达式过滤日志。 You'll need an app on indexer to do filtering based on the sourcetype defined in inputs.conf on the universal forwarder.您需要在索引器上安装一个应用程序,以根据通用转发器上的 input.conf 中定义的源类型进行过滤。

props.conf/transforms.conf combo provided below will keep only the log lines containing strings Error or Warning while all other messages will be sent to nullqueue (deleted).下面提供的 props.conf/transforms.conf 组合将仅保留包含字符串ErrorWarning的日志行,而所有其他消息将发送到 nullqueue (已删除)。

$SPLUNK_HOME$/etc/apps/your_app/local/props.conf $SPLUNK_HOME$/etc/apps/your_app/local/transforms.conf $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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM