匹配字段

%{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. 开发中CollectionUtils处理集合

    1.org.apache.commons.collections.CollectionUtils; 使用这个工具类,帮我们处理一些集合的操作,非常方便 //取并集public void testUni ...

  2. PAT L2-021 点赞狂魔

    https://pintia.cn/problem-sets/994805046380707840/problems/994805058485469184 微博上有个“点赞”功能,你可以为你喜欢的博文 ...

  3. HTML5 Base64_encoding_and_decoding

    https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding In JavaSc ...

  4. js拷贝实例;

    ,]]; // var arr2 =arr1.slice(0); // arr1[0] ="z"; // arr1[2][0] = "v"; // consol ...

  5. js字符串和正则表达式

    字符串的生成转换 你可以将任何类型的数据都转换为字符串,你可以用下面三种方法的任何一种: var myStr = num.toString(); // "19" var myStr ...

  6. BZOJ3732Network——kruskal重构树+倍增+LCA/最小生成树+倍增

    题目描述 给你N个点的无向图 (1 <= N <= 15,000),记为:1…N. 图中有M条边 (1 <= M <= 30,000) ,第j条边的长度为: d_j ( 1 & ...

  7. Dapper 连表查询

    实体类: UserInfo: public partial class UserInfo { public UserInfo() { this.Persion = new HashSet<Per ...

  8. BZOJ2839 : 集合计数 (广义容斥定理)

    题目 一个有 \(N\) 个 元素的集合有 \(2^N\) 个不同子集(包含空集), 现在要在这 \(2^N\) 个集合中取出若干集合(至少一个), 使得它们的交集的元素个数为 \(K\) ,求取法的 ...

  9. Selenium之WebDriver元素定位方法

    Selenium WebDriver 只是 Python 的一个第三方框架, 和 Djangoweb 开发框架属于一个性质. webdriver 提供了八种元素定位方法,python语言中也有对应的方 ...

  10. 【bzoj2007】 Noi2010—海拔

    http://www.lydsy.com/JudgeOnline/problem.php?id=2007 (题目链接) 题意 $(n+1)*(n+1)$的网格图上,相邻两点间有一些人流.左上角点的海拔 ...