ELK分析IIS日志

Posted Look Into Coding

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ELK分析IIS日志相关的知识,希望对你有一定的参考价值。

技术分享

 

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‘
  }
}

以上是关于ELK分析IIS日志的主要内容,如果未能解决你的问题,请参考以下文章

ELK:访问日志切割

ELK:访问日志切割

ELK:访问日志切割

elk日志分析搭建使用记录

elk日志分析搭建使用记录

ELK——ELK日志分析系统部署搭建