我正在尝试使用Logstash解析IIS错误XML文件,然后将这些错误存储在Elasticsearch中并在Kibana中显示。
这是我的logstash.conf文件:
input
{
file{
path => ["C:/inetpub/logs/FailedReqLogFiles/*/*.xml"]
start_position => "beginning"
# filter is not thread safe, so have to move the multiline into the input
codec => multiline{
#pattern => "^</failedRequest>"
pattern => "^<\?xml version"
negate => true
what => "previous"
max_lines => 12000
}
sincedb_path => "C:/Users/ss/Source/elk/logstash/bin/.sincedb"
}
}
filter{
xml{
store_xml => "false"
source => "message"
target => "EVENT"
xpath => [
"/failedRequest/@url", "url",
"/failedRequest/@appPoolId", "appPoolId",
"/failedRequest/@verb", "verb",
"/failedRequest/@statusCode", "statusCode"
]
}
}
output
{
elasticsearch{
hosts => ["100.202.191.77:9200"]
index => "testserver-logstash"
flush_size => 1
}
stdout
{
codec => rubydebug
}
file{
path => "C:/Users/ss/Source/elk/logstash/bin/test.log"
}
}
日志文件目录是:
C:\inetpub\logs\FailedReqLogFiles\W3SVC3
C:\inetpub\logs\FailedReqLogFiles\W3SVC4
C:\inetpub\logs\FailedReqLogFiles\W3SVC5
这些目录中包含的日志文件是:fr000001.xml,fr000002.xml,fr000003.xml,fr000004.xml等。
xml文件的结构如下:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="https://aaa.bbb.com:443/ddd.aspx"
siteId="3"
appPoolId="aaa.bbb.com"
processId="15168"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="NT AUTHORITY\IUSR"
authenticationType="anonymous"
activityId="{00000000-0000-0000-0200-0080030000FF}"
failureReason="STATUS_CODE"
statusCode="500"
triggerStatusCode="500"
timeTaken="368584"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">blablabla
</Event>
</failedRequest>
我遇到的问题是:总共有13个xml日志文件。我可以看到logstash输出在stdout和test.log中正确打印所有这13个文件的解析xml,但是,在Kibana中,我只能看到13个xml文件中的4个的数据,其余9个文件是失踪。
我是ELK堆栈的新手,真的被困在这里了。希望有人可以帮助我。提前致谢。
答案 0 :(得分:0)
我评论了该行,它看起来像logstash工作。
flush_size => 1