配置文件的基本格式,輸入部分,過濾器部分和輸出部分。
# This is a comment. You should use comments to describe # parts of your configuration. input { ... } filter { ... } output { ... }
每個部分都可以配置一個或多個插件。下面展示的是輸入部分,有兩個file插件。
input { file { path => "/var/log/messages" type => "syslog" } file { path => "/var/log/apache/access.log" type => "apache" } }
插件的值類型
數組
path => [ "/var/log/messages", "/var/log/*.log" ] path => "/data/mysql/mysql.log"
布爾
ssl_enable => true
字符串
name => "Hello world" name => 'It\'s a beautiful day'
哈希
match => { "field1" => "value1" "field2" => "value2" ... }
字節
my_bytes => "1113" # 1113 bytes my_bytes => "10MiB" # 10485760 bytes my_bytes => "100kib" # 102400 bytes my_bytes => "180 mb" # 180000000 bytes
代碼
codec => "json"
數值:浮點或整型
port => 33
密碼型:不會記錄到日誌或打印出來
my_password => "password"
路徑型:字符串
my_path => "/tmp/logstash"
註釋:使用#