匹配字段

%{TIMESTAMP_ISO8601:log_timestamp} (%{WORD:s-sitename}|-) (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) %{NOTSPACE:cs-referer} (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} %{NOTSPACE:cs-host} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-bytes}|-) (%{NUMBER:cs-bytes}|-) (%{NUMBER:time-taken}|-)

filter 规则1.0

if [type] =~ "winlog-" {
#删除iis日志中以#号开头的文件
if [message] =~ "^#" {
drop {}
}
#完成匹配和拆分iislog,并删除message字段。
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:log_timestamp} (%{WORD:s-sitename}|-) (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) %{NOTSPACE:cs-referer} (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} %{NOTSPACE:cs-host} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-bytes}|-) (%{NUMBER:cs-bytes}|-) (%{NUMBER:time-taken}|-)" }
remove_field => ["message"]
}
#按指定分隔符切割指定字段
mutate {
split => ["cs-uri-stem", "/ApiKey/"]
add_field => {
"tmpVinKey" => "%{[cs-uri-stem][1]}"
}
}
mutate {
split => ["tmpVinKey", "/"]
add_field => {
"apikey" => "%{[tmpVinKey][0]}"
}
add_field => {
"action_name" => "%{[tmpVinKey][1]}"
}
remove_field => ["tmpVinKey"]
}
#设置以字段访问时间的索引
date {
match => ["log_timestamp", "YYYY-MM-dd HH:mm:ss"]
target => "@timestamp"
}
}
}

filter 规则2.0

if [type] =~ "winlog-" {
#删除iis日志中以#号开头的文件
if [message] =~ "^#" {
drop {}
}
#完成匹配和拆分iislog,并删除message字段。
#完善iis字段
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:log_timestamp} (%{WORD:s-sitename}|-) (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) %{NOTSPACE:cs-referer} (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} %{NOTSPACE:cs-host} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-substatus}|-) (%{NUMBER:sc-win32-status}|-) (%{NUMBER:sc-bytes}|-) (%{NUMBER:cs-bytes}|-) (%{NUMBER:time-taken}|-)" }
remove_field => ["message"]
}
#复制field
mutate {
add_field => {"request" => "%{cs-uri-stem}"}
}
#按指定分隔符切割指定字段
mutate {
split => ["request", "/ApiKey/"]
add_field => {
"tmpVinKey" => "%{[request][1]}"
}
}
mutate {
split => ["tmpVinKey", "/"]
add_field => {
"apikey" => "%{[tmpVinKey][0]}"
}
add_field => {
"action_name" => "%{[tmpVinKey][1]}"
}
remove_field => ["tmpVinKey"]
remove_field => ["request"]
}
#设置以字段访问时间的索引
date {
match => ["log_timestamp", "YYYY-MM-dd HH:mm:ss"]
target => "@timestamp"
}
}
}

filter 规则3.0以及output

if [type] =~ "winlog-" {
if [message] =~ "^#" {
drop {}
} mutate {
add_field => {"line_message" => "%{message} %{offset}"}
}
ruby {
code => "
require 'digest/md5';
event.set('computed_id', Digest::MD5.hexdigest(event.get('line_message')))
"
}
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:log_timestamp} (%{WORD:s-sitename}|-) (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) %{NOTSPACE:cs-referer} (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} %{NOTSPACE:cs-host} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-substatus}|-) (%{NUMBER:sc-win32-status}|-) (%{NUMBER:sc-bytes}|-) (%{NUMBER:cs-bytes}|-) (%{NUMBER:tme-taken}|-)" }
remove_field => ["message","[beat][name]","[beat][version]"]
}
mutate {
add_field => {"request" => "%{cs-uri-stem}"}
}
mutate {
split => ["request", "/ApiKey/"]
add_field => {
"tp" => "%{[request][1]}"
}
}
mutate {
split => ["tp", "/"]
add_field => {
"apikey" => "%{[tp][0]}"
}
add_field => {
"action_name" => "%{[tp][1]}"
}
remove_field => ["tp"]
remove_field => ["request","line_message"]
}
date {
match => ["log_timestamp", "YYYY-MM-dd HH:mm:ss"]
target => "@timestamp"
timezone => "Etc/UTC"
}
}
} elasticsearch {
hosts => ["192.168.1.150:9200"]
user => logstash_internal
password => changeme
index => "%{type}-%{+YYYY.MM.dd}"
document_type => "%{type}"
document_id => "%{computed_id}"
template_overwrite => true
}

  

logstash收集IIS日志的更多相关文章

  1. Logstash 收集 IIS 日志

    日志样例 查看 IIS 日志配置,选择格式为 W3C(默认字段设置)保存生效. 2016-02-25 01:27:04 112.74.74.124 GET /goods/list/0/1.html - ...

  2. logstash 收集 IIS 日志实践

    IIS日志示例: 2017-02-20 00:55:40 127.0.0.1 GET /MkWebAPI/swagger/ui/index - 80 - 127.0.0.1 Mozilla/5.0+( ...

  3. logstash收集syslog日志

    logstash收集syslog日志注意:生产用syslog收集日志!!! 编写logstash配置文件 #首先我用rubydebug测试数据 [root@elk-node1 conf.d]# cat ...

  4. logstash收集springboot日志

    logstash收集springboot日志 maven依赖 <dependency> <groupId>net.logstash.logback</groupId> ...

  5. logstash收集的日志输出到elasticsearch中

    logstash收集的日志输出到elasticsearch中 一.需求 二.实现步骤 1.编写pipeline文件 1.`elasticsearch`配置参数解析: 2.可能会报的一个异常 2.准备测 ...

  6. logstash收集rsyslog日志

    (1)rsyslog配置 在192.168.1.31配置 #vim /etc/rsyslog.conf *.* @@192.168.1.32:514 //所有设备名,所有日志级别都发送到192.168 ...

  7. logstash收集java日志,多行合并成一行

    使用codec的multiline插件实现多行匹配,这是一个可以将多行进行合并的插件,而且可以使用what指定将匹配到的行与前面的行合并还是和后面的行合并. 1.java日志收集测试 input { ...

  8. 构建Logstash+tomcat镜像(让logstash收集tomcat日志)

    1.首先pull logstash镜像作为父镜像(logstash的Dockerfile在最下面): 2.构建my-logstash镜像,使其在docker镜像实例化时,可以使用自定义的logstas ...

  9. Logstash收集nginx日志之使用grok过滤插件解析日志

    grok作为一个logstash的过滤插件,支持根据模式解析文本日志行,拆成字段. nginx日志的配置: log_format main '$remote_addr - $remote_user [ ...

随机推荐

  1. 13.14.15.16.17&《一个程序猿的生命周期》读后感

    13.TDS 的标准是什么,怎么样才能认为他是一个标准的TDS?? 14.软件的质量包括哪些方面,如何权衡软件的质量? 15.如何解决功能与时间的矛盾,优秀的软件团队会发布有已知缺陷的软件么? 16. ...

  2. eclipse插件wordwrap

    一行代码很长,浏览不方便,安装wordwrap可以自动折行. help->install new software-,在Workwith输入wordwrap - http://ahtik.com ...

  3. Spring Cloud Zipkin

    Zipkin the idea is from the googlge paper:Dapper https://yq.aliyun.com/articles/60165 https://www.e4 ...

  4. ECSHOP广告调用广告位添加到首页顶部通栏教程

    ECSHOP广告调用广告位添加到首页顶部通栏教程 ECSHOP教程/ ecshop教程网(www.ecshop119.com) 2012-05-26   ECSHOP系统默认预留的广告位很少,如何才能 ...

  5. 临时关闭Mysql ONLY_FULL_GROUP_BY

    /** * @author lcc807@ikoo8.com * * 临时关闭Mysql ONLY_FULL_GROUP_BY */ function closeSqlFullMode(){ DB:: ...

  6. Delphi中的Sender:TObject对象解析

    Delphi中的Sender:TObject对象解析 procedure TForm1.Button1Click(Sender: TObject); begin end; 解析:Procedure是过 ...

  7. delphi 的 LockType 锁类型

    LockType     锁类型       常数                                         值                           说明     ...

  8. C# 语言习惯

    目录 一.使用属性而不是可访问的数据成员 二.使用运行时常量(readonly)而不是编译时常量(const) 三.推荐使用 is 或 as 操作符而不是强制类型转换 四.使用 Conditional ...

  9. Python调用C++类

    http://blog.csdn.net/liyuan_669/article/details/25361655 C++导出类到Python http://blog.csdn.net/arnozhan ...

  10. Lucene最重要的功能是对一段话的分析

    Lucene最重要的功能是对一段话的分析