题外内容:
因本IIS服务器经过硬件负载均衡进行代理转,导致IIS无法直接识别出外部客户端IP地址,因此需要安装x_forward_for功能用于识别,参考如下文章:https://blog.csdn.net/hzfw2008/article/details/105066565/
一、Windows下载安装Logstash
下载地址:https://www.elastic.co/cn/downloads/logstash 备注:下载解压后,即可直接使用,不需要额外安装JAVA
二、设置IIS的格式输出
三、IIS输出的日志内容
2021-09-18 00:01:55 10.224.48.91 GET /news_d.aspx 220.181.108.83 3ww.junhua.net 200 35
四、Logstash解释IIS配置文件
input {
file {
path => ["C:/inetpub/logs/wmsvc/W3SVC2/*.log"]
type => "web-iis"
}
}
filter {
grok {
match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} %{IPORHOST:serverip} %{WORD:method} %{URIPATH:page} %{IPORHOST:clientip} %{NUMBER:status} %{NUMBER:respone_time}"]
}
geoip {
source => "clientip"
target => "geoip"
add_field => ["[geoip][coordinates]","%{[geoip][longitude]}"]
add_field => ["[geoip][coordinates]","%{[geoip][latitude]}"]
}
}
output {
elasticsearch {
user => "elastic"
password => "password"
hosts => ["http://10.224.14.14:9200","http://10.224.14.15:9200","http://10.224.14.16:9200"]
index => "logstash-%{type}-%{+YYYY.MM.dd}"
}
}