格式、语法、使用方式:
# 注释.
input {
...
}
filter {
...
}
output {
...
}
## 两个input设置:
input {
file {
path => "/var/log/messages"
type => "syslog"
}
file {
path => "/var/log/apache/access.log"
type => "apache"
}
}
## 数据类型:
## bool类型
debug => true
## string类型
host => "hostname"
## number类型
port => 6789
## array or list类型
path => ["/var/log/message","/var/log/*.log"]
## hash类型
match => {
"field1" => "value1"
"field2" => "value2"
}
## codec类型
codec => "json"
##字段引用方式:
{
"agent": "Mozilla/5.0 (compatible; MSIE 9.0)",
"ip": "192.168.24.44",
"request": "/index.html"
"response": {
"status": 200,
"bytes": 52353
},
"ua": {
"os": "Windows 7"
}
}
##获取字段值:
[response][status]
[ua][os]
## 条件判断condition:
if EXPRESSION {
...
} else if EXPRESSION {
...
} else {
...
}
==(等于), !=(不等于), <(小于), >(大于), <=(小于等于), >=(大于等于), =~(匹配正则), !~(不匹配正则)
in(包含), not in(不包含), and(与), or(或), nand(非与), xor(非或)
()(复合表达式), !()(对复合表达式结果取反)
## 使用环境变量(缺失报错):
input {
tcp {
port => "${TCP_PORT}"
}
}
## 使用环境变量(缺失使用默认值):
input {
tcp {
port => "${TCP_PORT:54321}"
}
}