这篇文章主要讲解了“如何实现在Docker上安装logstash”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何实现在Docker上安装logstash”吧!
编辑docker-compose.yml,内容如下:
version: '3' services: logstash02: image: logstash:6.4.1 hostname: logstash02 container_name: logstash02 ports: - "5045:5045" #设置端口 environment: XPACK_MONITORING_ENABLED: "false" pipeline.batch.size: 10 volumes: - ./logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf network_mode: "host" restart: always
./logstash/logstash.conf文件内容如下:
version: '3' services: logstash02: image: logstash:6.4.1 hostname: logstash02 container_name: logstash02 ports: - "5045:5045" #设置端口 environment: XPACK_MONITORING_ENABLED: "false" pipeline.batch.size: 10 volumes: - ./logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf network_mode: "host" restart: always
然后运行docker-compose up启动logstash容器,在进行logstash测试的时候,
/usr/share/logstash/bin/logstash -e 'input { stdin{} } output { stdout{ codec => rubydebug }}'
会提示 logstash实例已存在,如果要运行多个logstash实例,则需要通过命令定义path.data,如下:
bin/logstash -f <config_file.conf> --path.data PATH
/usr/share/logstash/bin/logstash --path.data /usr/share/logstash/data02 -e 'input { stdin{} } output { stdout{ codec => rubydebug }}'
输出如下:
输出到ES、文件:
/usr/share/logstash/bin/logstash --path.data /usr/share/logstash/data02 -e 'input { stdin{} } output { elasticsearch {hosts => ["127.0.0.1:9200"] index => "logstashtest_%{+YYYY.MM.dd}" }}' /usr/share/logstash/bin/logstash -e 'input { stdin{} } output { file { path => "/tmp/test_%{+YYYY.MM.dd}.log"}}'
感谢各位的阅读,以上就是“如何实现在Docker上安装logstash”的内容了,经过本文的学习后,相信大家对如何实现在Docker上安装logstash这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。