Docker安装logstash的详细过程
程序员文章站
2022-06-25 21:00:05
编辑docker-compose.yml,内容如下:version: '3'services: logstash02: image: logstash:6.4.1 hostname: l...
编辑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内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!