文章目录

操作说明

官方文档
​​​ https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html​

只需要自己编辑一个配置文件,比如​​lab.conf​​​ 然后运行​​logstash.bat -f lab.conf​​即可


elasticsearch => json file

input {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "test"
query => '{ "query": {"match_all" : {} } }'
}
}
output {
file {
path => "D:/logstash-7.15.1-windows-x86_64/logstash-7.15.1/config/a.json"
}
}

elasticsearch => elasticsearch

input {
elasticsearch {
hosts => "192.168.71.177:9200"
index => "test"
query => '{ "query": {"match_all" : {} } }'
}
}
output {
elasticsearch {
hosts => "192.168.71.128:9200"
index => "%{[@metadata][_index]}"
document_id => "%{[@metadata][_id]}"
}
}

json file => elasticsearch

input {
file {
path => "D:/logstash-7.15.1-windows-x86_64/logstash-7.15.1/config/a.log"
start_position => "beginning"
codec => json {
charset => "UTF-8"
}
}
}
output {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "xxxxxxxxxxxxxx"
}
}