Logstash配置语法以及插件
配置语法
处理输入的input
处理过滤的filter
处理输出的output
简单的配置语句:
input {
stdin {
}
}
output{
stdout{
}
}
语法格式
区域
用{}定义区域
区域内可定义插件
数据类型(布尔值,字符串,数值,数组,哈希)
布尔 boolean : ssl_enable => true
字节 Bytes :my_bytes => "10MiB" # 10485760 bytes
字符串 String:name => "Hello world“
数值 Number:port => 514
数组 Array:match => ["datetime", "UNIX", "ISO8601"]
哈希 Hash:
options => {
key1 => "value1",
key2 => "value2"
}
编码解码: codec :codec => “json”
密码型: my_password => “password”
路径: my_path => "/tmp/logstash“
注释: #
条件判断
==(等于), !=(不等于), <(小于), >(大于), <=(小于等于), >=(大于等于)
=~(匹配正则), !~(不匹配正则)
in(包含), not in(不包含)
and(与), or(或), nand(非与), xor(非或)
():复合表达式, !():对复合表达式结果取反
字段引用
Logstash 还支持变量内插,在字符串里使用字段引用的方法是这样
output{
statsd {
increment => "apache.%{[response][status]}"
}
}
插件介绍
inputs 就是输入
codecs 就是解码
filters 就是过滤
outputs 输出
插件获取地址:
https://github.com/logstash-plugins
在线安装:
/plugin install logstash-input-jdbc
卸载插件:
/plugin uninstall logstash-input-jdbc
淘宝源地址: https://ruby.taobao.org
gem sources --remove
gem sources -a https://ruby.taobao.org/
gem sources -l
转载于:https://my.oschina.net/eddylinux/blog/600998