docker pull logstash:7.7.0
2.本地创建logstash.yml文件,内容如下:
#http.host: "0.0.0.0"
#xpack.monitoring.elasticsearch.url: http://0.0.0.0:9200
3.本地创建配置test.conf文件,文件内容如下:
input {
tcp {
host => "0.0.0.0"
port => 4560
mode => "server"
tags => ["tags"]
codec => json_lines
}
stdin {
}
}
output {
elasticsearch {
hosts => "10.7.11.191:9200"
index => "logstash-%{+YYY.MM.dd}"
}
}
4.启动docker容器命令如下:
docker run --rm -d -it --name=logstash -p 4560:4560 \
-v $(pwd)/message:/usr/share/logstash/config/messages \
-v $(pwd)/test.conf:/usr/share/logstash/pipeline/test.conf \
-v $(pwd)/logstash.yml:/usr/share/logstash/config/logstash.yml \
logstash:7.7.0
5.使用docker logs查看启动状态
docker logs -f logstash