Logstash
描述:看图
Logstash下载链接:https://www.elastic.co/cn/downloads/logstash
解压,,查看:
logstash配置分三部分:
input {
stdin {...} #标准输入
}
filter { #过滤,分割,截取等处理
...
}
output {
stdout {...} #标准输出
}
编写配置文件myngx.cnf:
input {
file {
path => "/usr/local/nginx/logs/test.log" #创建一个test.log
start_position => "beginning" #开始
}
}
filter {
mutate {
split => {"message"=>"|"} #过滤以"|"为分割的字段
}
}
output {
stdout { codec => rubydebug }
}
创建一个test.log文件到指定位置
echo "2020-3-25-16-09-52|ERROR MESSAGE|测试报错了|参数:balabalabababa">/usr/local/nginx/logs/test.log
在Logstash根目录执行
./bin/logstash -f myngx.conf
等待输出
![](https://img2020.cnblogs.com/i-beta/1756712/202003/1756712-20200325220428463-658902521.png)
=================================================
如何把收集到的,整理好的文件传送给Elasticsearch呢?呢呢?呢?修改配置文件,
input { file { path => "/usr/local/nginx/logs/test.log" start_position => "beginning" } } filter { mutate { split => {"message"=>"|"} } } output { elasticsearch { hosts => ["192.168.28.30:9200"] } } #output { # stdout { codec => rubydebug } #}