首先,谢谢你的建议和时间。
我最近为我刚开始工作的公司设置了一个Elk堆栈。(这是我第一次使用Logstash和Nxlog。)我想做的是使用nxlog将IIS日志和EventLogs从同一个the服务器发送到logstash。
我只是不明白如何从一个源发送两种类型的日志,并让logstash.conf正确地过滤这些数据。
这是我的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/nxlog-docs/en/nxlog-reference-manual.html
## 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 json>
Module xm_json
</Extension>
<Input iis_1>
Module im_file
File "F:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log"
ReadFromLast True
SavePos True
Exec if $raw_event =~ /^#/ drop();
</Input>
<Input iis_2>
Module im_file
File "F:\inetpub\logs\LogFiles\W3SVC2\u_ex*.log"
ReadFromLast True
SavePos True
Exec if $raw_event =~ /^#/ drop();
</Input>
<Input iis_4>
Module im_file
File "F:\inetpub\logs\LogFiles\W3SVC4\u_ex*.log"
ReadFromLast True
SavePos True
Exec if $raw_event =~ /^#/ drop();
</Input>
<Input eventlog>
Module im_msvistalog
Exec $EventReceivedTime = integer($EventReceivedTime) / 1000000; to_json();
</Input>
<Output out_iis>
Module om_tcp
Host 10.191.132.86
Port 5555
OutputType LineBased
</Output>
<Route 1>
Path iis_1, iis_2, iis_4, eventlog=> out_iis
</Route> 我现在的logstash.conf
input {
tcp {
type => "iis"
port => 5555
host => "10.191.132.86"
}
}
filter {
if [type] == "iis" {
grok {
match => ["@message", "%{TIMESTAMP_ISO8601:timestamp} %{IPORHOST:hostip} %{WORD:method} %{URIPATH:page} %{NOTSPACE:query} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:clientip} %{NOTSPACE:useragent} %{NOTSPACE:referrer} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:scstatus} %{NUMBER:timetaken}"]
}
}
}
output {
elasticsearch {
protocol => "http"
host => "10.191.132.86"
port => "9200"
}
}看起来,您可以通过设置类型来筛选不同的数据,如果键入了其他类型,则可以这样做。但是,如果它们来自同一个来源,我如何指定不同的类型?
))谢谢!
发布于 2015-04-17 19:27:25
这样做的一种方法是通过每个日志中已知的记录条目进行筛选,而在另一个日志中不存在,例如cs_bytes等。
例如:
if [iisfield] {
mark type as IIS
else
mark type as EventLog
}我已经编写了一个IIS和事件日志代理,它捕获了Logit.io的日志,他们可能已经完成了您想要的一切。
发布于 2015-04-18 10:14:26
NXLog用iis_1、iis_2等值设置字段SourceModuleName。您可能需要使用它。
https://stackoverflow.com/questions/29704029
复制相似问题