Logstash 配置(四)output配置
写入到ES(重点)
[root@bigdata111 confs_test]# vi output_es_stdin.conf
配置:
input {
stdin {
type => "log2es"
}
}
output {
elasticsearch {
hosts => ["192.168.212.111:9200"]
index => "logstash-%{type}-%{+YYYY.MM.dd}"
document_type => "%{type}"
sniffing => true
template_overwrite => true
}
}
注:
sniffing:是否寻找其它节点(如果是一个集群中的节点,一个节点没连接上,是否要连接其他节点)
------------------------------------------------
启动ES-是用非root用户启动的:
[root@bigdata111 ~]# su demouser
[demouser@bigdata111 root]$ cd /usr/local/elasticsearch-6.1.1
[demouser@bigdata111 elasticsearch-6.1.1]$ bin/elasticsearch
启动LS:
[root@bigdata111 confs_test]# ../bin/logstash -f ./output_es_stdin.conf
启动好后在控制台输入数据:hello hello hello
在head插件中可以看到数据。
sniffing : 寻找其他es节点