输入内容中最好不要出现 "type":"...",key为type的json。它会覆盖配置文件中的type。致使type不相等,不执行output es操做。git
好比json:{"type":"123"}github
logstash配置文件为:shell
input {
kafka {
bootstrap_servers => "111.111.1.1:9092"
topics => ["test"]
group_id => "test_group_main"
client_id => "test_kafka_client_25"
type => "test_logstash_25"
}
}
filter {
if [type] == "test_logstash_25" {
json {
source => "message"
remove_field => ["message"]
}
}
}
output {
if [type] == "test_logstash_25" { #这里的type值变成了123,取自json。致使不存es库。
elasticsearch {
hosts=> ["111.111.11.111:9200"]
index=> "my_test-%{+YYYY.MM.dd}"
codec => json
}
}
}
自动从新加载配置json
为了能够自动检测配置文件的变更和自动从新加载配置文件,须要在启动的时候使用如下命令:bootstrap
./bin/lagstash -f configfile.conf --config.reload.automatic
1
默认,检测配置文件的间隔时间是3秒,能够经过如下命令改变jvm
--config.reload.interval <second>
1
若是已经运行了没有提供自动重启的logstash,能够发送一个挂起命令给logstash从新加载配置文件:elasticsearch
kill -1 <pid>
1
配置文件自动重载工做原理spa
检测到配置文件变化
经过中止全部输入中止当前pipline
用新的配置建立一个新的管道
检查配置文件语法是否正确
检查全部的输入和输出是否能够初始化
检查成功使用新的pipeline替换当前的pipeline,
检查失败,使用旧的继续工做.
在重载过程当中,jvm没有重启..net
注意事项插件
stdin输入插件不支持自动重启.
syslog做为输入源,当重载配置文件时,会崩溃.请看: https://github.com/logstash-plugins/logstash-input-syslog/issues/40
---------------------
做者:落叶下的光
来源:CSDN
原文:https://blog.csdn.net/qq_32292967/article/details/78622647
版权声明:本文为博主原创文章,转载请附上博文连接!
启动时加载目录下全部配置文件:配置文件必需要以 config 为后缀。 yml在指定单个能够执行,批量就不认了!!!
bin/logstash -f ./config/ (bin/logstash -f ./config/*仍是启动第一个)
须要用pipeline.xml
验证正确性:
bin/logstash -f first-pipeline.conf --config.test_and_exit
bin/logstash -f first-pipeline.conf --config.reload.automatic 自动加载./bin/logstash --path.settings ./bak.config/ 本身设定config目录