Nxlog日志过滤

一般情况下nxlog只用于windows2008以及以上版本的日志转发(即使用im_msvistalog模式),实测08以下版本日志转发时出现乱码。

 

 im_msvistalog使用以下字段

 

$raw_event (type: string)
包含$EventTime、$Hostname、$Severity、$EventID和$Message的字符串
$AccountName (type: string)
与事件关联的用户名。
$AccountType (type: string)
包含$EventTime、$Hostname、$Severity、$EventID和$Message的字符串
$ActivityID (type: string)
当前活动的全局惟一标识符,存储在EvtSystemActivityID中。
$Category (type: string)
从任务解析的类别名称。
$Channel (type: string)
 事件源的通道 (例如,安全性或应用程序)。
$Domain (type: string)
用户的域名。
$EventID (type: integer)
EvtSystemEventID字段中的事件ID(特定于事件源)。
$EventTime (type: datetime)
EvtSystemTimeCreated 字段
$EventType (type: string)
事件的类型,它是一个描述严重性的字符串。这将从EvtSystemLevel转换为它的字符串表示形式。可能的值有:CRITICAL、ERROR、AUDIT_FAILURE、AUDIT_SUCCESS、INFO、WARNING和VERBOSE。
$EventXML (type: string)
XML格式的原始事件数据。如果模块的CaptureEventXML指令设置为TRUE,则此字段可用。
$ExecutionProcessID (type: integer)
事件生成器的进程标识符,如EvtSystemProcessID。
$Hostname (type: string)
EvtSystemComputer 字段.
$Keywords (type: string)
EvtSystemKeywords字段的值。
$Message (type: string)
事件的消息。
$Opcode (type: string)
从OpcodeValue解析的操作码字符串。
$OpcodeValue (type: integer)
事件在EvtSystemOpcode中的操作码号。
$ProviderGuid (type: string)
事件提供者的全局唯一标识符,存储在EvtSystemProviderGuid中。这对应于$SourceName字段中的提供者名称。
$RecordNumber (type: integer)
事件记录的数目。.
$RelatedActivityID (type: string)
存储在EvtSystemRelatedActivityID中的RelatedActivityID。
$Severity (type: string)
事件的标准化严重性名称。请参见$ SeverityValue。
$SeverityValue (type: integer)
事件的规范化严重程度编号,映射见表格。
$SourceName (type: string)
从EvtSystemProviderName字段生成事件的事件源。
$TaskValue (type: integer)
EvtSystemTask字段中的任务编号。
$ThreadID (type: integer)
事件生成器的线程标识符,如EvtSystemThreadID中所示。
$UserID (type: string)
安全标识符(SID),解析为$AccountName,存储在EvtSystemUserID中。
$Version (type: integer)
事件在EvtSystemVersion中的版本号

表格

Event Log Severity

Normalized Severity

0/Audit Success

2/INFO

0/Audit Failure

 

4/ERROR

0/Audit Failure

 

5/CRITICAL

2/Error

 

4/ERROR

3/Warning

3/WARNING

4/Information

2/INFO

5/Verbose

1/DEBUG

 

常规nxlog.conf内容

## This is a sample configuration file. See the nxlog reference manual about the
## configuration options. It should be installed locally and is also available
## online at http://nxlog.org/docs/

## Please set the ROOT to the folder your nxlog was installed into,
## otherwise it will not start.

#define ROOT C:\Program Files\nxlog
define ROOT C:\Program Files (x86)\nxlog

Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log

<Extension _syslog>
    Module      xm_syslog
</Extension>

<Input in>
    Module      im_msvistalog 
# For windows 2003 and earlier use the following:
#   Module      im_mseventlog
</Input>

<Output out>
    Module      om_udp # 日志转发协议
    Host        172.168.1.20 # 日志接收端IP
    Port        514 # 接收端PORT
    Exec        to_syslog_snare();
</Output>

<Route 1>
    Path        in => out
</Route>

 

注:以下过滤方式只适用于Module im_msvistalog,nxlog配置就不介绍了,请在nxlog正常使用的情况下使用该文档操作

 

过滤操作:使用Exec if $xxx == xxx drop ();

通过指定regex来添加筛选器。NXLOG以NXLOG语言(在语法上与PERL非常相似)的形式提供了用户脚本功能。为了使用regex进行筛选,我们添加了一个Exec命令,它实际上逐行遍历输入并执行脚本。

 

例如:滤掉raw_event字段中提到“Read”的任何事件日志,并且只针对EventID 400,那么你可以执行以下操作:

 

Exec if $EventID == 400 and ( $Message =~ /Read/m ) drop ();

例如:过滤掉包含dumpus.exe || nxlog.exe || java.exe || ...的任何事件日志,那么你可以执行以下操作:

Exec if  $Message =~  /.dumpus\.exe?/ OR \
        $Message =~  /java\.exe?/ OR \
        $Message =~  /nxlog\.exe?/  drop();

 

其他条件可参照上文提供的字段编写规则进行操作。

 

参考:https://www.rexconsulting.net/applying-double-filters-nxlog-windows-event-logs.html

参考:https://www.rexconsulting.net/adding-additional-layer-filtering-nxlog.html

参考:https://nxlog.co/question/3469/how-forward-event-ids-specific-process-names

 

 

 

 

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值