匹配字段

%{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. SRS用例

    团队项目:超市管理系统     作者:王琨  个人博客地址:http://www.cnblogs.com/wangkun123 一. 用例视图概述 一般的超市商品管理系统,主要由五大模块组成,即商品信 ...

  2. React16新特性

    React的16版本采用了MIT开源许可证,新增了一些特性. Error Boundary render方法新增返回类型 Portals 支持自定义DOM属性 setState传入null时不会再触发 ...

  3. 3-Python3从入门到实战—基础之数据类型(数字-Number)

    Python从入门到实战系列--目录 Python3 中有六个标准的数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionar ...

  4. Docker Clustering Tools Compared: Kubernetes vs Docker Swarm

    https://technologyconversations.com/2015/11/04/docker-clustering-tools-compared-kubernetes-vs-docker ...

  5. Layui_Tree模块遍历HDFS

    注:转载请署名 一.实体 package com.ebd.application.common.Base; import java.util.List; public class HDFSDir { ...

  6. Educational Codeforces Round 4 C. Replace To Make Regular Bracket Sequence

    题目链接:http://codeforces.com/contest/612/problem/C 解题思路: 题意就是要求判断这个序列是否为RBS,每个开都要有一个和它对应的关,如:<()> ...

  7. IDEA如何刷新pom文件

    被新手问到了“IDEA如何刷新pom文件?”这个问题,想来这是一个不好意思问的常犯的错误吧. 在IDEA中,修改了pom.xml文件,添加了依赖以后,一般会弹出以下这个警告来. 点击[Import C ...

  8. apache 限制连接并发数和下载速度

    apache 限制并发数 需要安装:mod_limitipconn模块 安装方法:yum install mod_limitipconn 安装完成后: 检查 Apache 模块目录,看是否含有 mod ...

  9. 22 Zabbix系统版本升级过程

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 22 Zabbix系统版本升级过程 Zabbix升级与其他相类似系统升级一样,前提一定做好备份,备 ...

  10. 自学Zabbix3.12.3-动作Action-自动发现action配置

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix3.12.3-动作Action-自动发现action配置 1. 首先先学习  Ne ...