在本快速教程中,我们将介绍如何使用 nxlog 收集、发送和转发 IIS 日志到 Graylog 2 服务器。
本教程假设我们已经在 Windows 服务器上安装了 Graylog 2 Server 和 Nxlog。
配置 NXLog
打开 nxlog.conf 文件并修改如下,确保将 YOUR_GRAYLOG_IP 替换为 Graylog 服务器的 IP 地址,并将 C:\inetpub\logs\LogFiles\W3SVC1\u_ex* 替换为 iis 日志目录的路径:
#######################################################################
#### EXTENTIONS #####
#######################################################################
<Extension _gelf>
Module xm_gelf
</Extension>
<Extension _json>
Module xm_json
</Extension>
#######################################################################
#### IIS NXLOG ######
#######################################################################
<Extension w3c>
Module xm_csv
Fields $date, $time, $s_ip, $cs_method, $cs_uri_stem, $cs_uri_query, $s_port, $cs_username, $c_ip, $cs_User_Agent, $cs_Referer, $sc_status, $sc_substatus, $sc_win32_status, $time_taken
FieldTypes string, string, string, string, string, string, string, string, string, string, string, string, string, string, string
Delimiter ' '
QuoteChar '"'
EscapeControl FALSE
UndefValue -
</Extension>
<Input iis>
Module im_file
File "C:\inetpub\logs\LogFiles\W3SVC1\u_ex*"
SavePos TRUE
Exec if $raw_event =~/^#/drop();\
else\
{\
w3c->parse_csv();\
$EventTime = parsedate($date + " " + $time);\
$EventTime = parsedate($date + " " + $time + "Z");\
$SourceName = "IIS";\
$raw_event = to_json();\
}
</Input>
<Output graylog>
Module om_udp
Host YOUR_GRAYLOG_IP
Port 12201
OutputType GELF
Exec $Hostname = hostname_fqdn();
Exec $raw_event =$Hostname + ' IIS-NXLOG ' + $raw_event;
#Use the following line for debugging (uncomment the fileop extension above as well)
#Exec file_write("C:\Program Files (x86)\nxlog\data\nxlog_output.log", $raw_event);
</Output>
<Route iis-to-graylog>
Path iis => graylog
</Route>
#######################################################################
#### /IIS NXLOG #####
#######################################################################
创建 Graylog 输入
- 使用以下链接登录 Graylog Web 界面(根据我们使用的机器的 IP 进行更改),如果我们想:
- 点击 System/Inputs ,然后选择 Inputs
- 选择 GELF UDP 并点击 Launch new input
- 将显示一个新的弹出窗口。
选择一个相关的标题,选择绑定地址应该是 Graylog 机器的 IP 并最终保存。
- 将显示一个新的弹出窗口。
日期:2020-06-02 22:18:25 来源:oir作者:oir
