ELK分析IIS日志

配置Logstash处理IIS日志
本文介绍如何使用Logstash配置文件来处理IIS Web服务器的日志文件。通过特定的输入路径设置、过滤器及输出配置,可以实现对日志文件的有效解析,并将解析后的数据发送到Elasticsearch进行存储。

image

 

LogStash.conf

input {
  file {
    type => "iis_log"
    path => ["C:/inetpub/logs/LogFiles/W3SVC2/u_ex*.log"]
  }
}
filter {
  #ignore log comments
  if [message] =~ "^#" {
    drop {}
  }

  grok {
    # check that fields match your IIS log settings
    match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) (%{NOTSPACE:c-username}|-) (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-win32-status}|-) (%{NUMBER:time-taken}|-)"]
  }
  #Set the Event Timesteamp from the log
	date {
		match => [ "log_timestamp", "YYYY-MM-dd HH:mm:ss" ]
		timezone => "Etc/UCT"
		}
  mutate {
			remove_field => [ "log_timestamp"]
			convert => [ "sc-bytes", "float" ]
			convert => [ "cs-bytes", "float" ]
			convert => [ "time-taken", "float" ]
		}
    
  mutate {
    remove_field => [ "log_timestamp"]
	convert => [ "sc-bytes", "float" ]
    convert => [ "cs-bytes", "float" ]
    convert => [ "time-taken", "float" ]
  }

}
output {
  stdout {codec => rubydebug }
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "logstash-%{type}-%{+YYYY.MM.dd}"
		flush_size => 20000
        idle_flush_time => 10
        template_overwrite => true
    }
  redis {
    host => '127.0.0.1'
    data_type => 'list'
    key => 'logstash:redis'
  }
}

转载于:https://www.cnblogs.com/HQFZ/p/6249568.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值