Redis 服务器是Logstash 推荐的Broker选择,Broker 角色就意味会同时存在输入和输出两个插件。 5.1.1 读取Redis 数据 LogStash::Input::Redis 支持三种data_type(实际上是redis_type), 不同的数据类型会导致实际采用不同的Redis命令操作: 1. 配置示例: zjtest7-frontend:/usr/local/logstash-2.3.4/config/redis# cat redis01.conf input { redis { data_type =>"pattern_channel" key=>"logstash-redis01" host => "192.168.32.67" password => "1234567" port =>"6379" } } output { stdout { codec => rubydebug } } redis 输入: 127.0.0.1:6379> PUBLISH logstash-redis01 "hello 20160912 world" (integer) 1 127.0.0.1:6379> [elk@zjtest7-frontend redis]$ ../../bin/logstash -f redis01.conf Settings: Default pipeline workers: 1 Pipeline main started { "message" => "hello 20160912 world", "tags" => [ [0] "_jsonparsefailure" ], "@version" => "1", "@timestamp" => "2016-09-12T01:31:47.292Z" } 5.1.2 采用list类型扩展Logstash 通过频道发布的一条消息,会被所有订阅了该频道的Logstash 进程同时接收到,然后输出重复内容: 1. [elk@zjtest7-frontend redis]$ ../../bin/logstash -f redis01.conf Settings: Default pipeline workers: 1 Pipeline main started { "message" => "hello 20160912 world", "tags" => [ [0] "_jsonparsefailure" ], "@version" => "1", "@timestamp" => "2016-09-12T01:31:47.292Z" } { "message" => "hello 20160912 aaaa bbbb world", "tags" => [ [0] "_jsonparsefailure" ], "@version" => "1", "@timestamp" => "2016-09-12T01:40:12.672Z" } 2. [elk@zjtest7-frontend redis]$ ../../bin/logstash -f redis01.conf Settings: Default pipeline workers: 1 Pipeline main started { "message" => "hello 20160912 aaaa bbbb world", "tags" => [ [0] "_jsonparsefailure" ], "@version" => "1", "@timestamp" => "2016-09-12T01:40:13.466Z" } 这种情况下,就需要使用list类型,在这种类型下,数据输入到Redis 服务器上暂存,Logstash 则连上Redis 服务器取走数据