zoukankan      html  css  js  c++  java
  • 5.1.1 读取Redis 数据

    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 服务器取走数据
    

  • 相关阅读:
    线段树(区间合并) LA 3989 "Ray, Pass me the dishes!"
    BIT LA 4329 Ping pong
    并查集(路径更新) LA 3027 Corporative Network
    log4j.properties配置详解与实例-全部测试通过
    ActiveMQ入门实例
    activemq安全设置 设置admin的用户名和密码
    Freemarker入门小案例(生成静态网页的其中一种方式)
    maven项目在myeclipse中不出现Maven Dependencies 和maven标识的解决方法
    Mysql,SqlServer,Oracle主键自动增长的设置
    常用SQL语句
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350276.html
Copyright © 2011-2022 走看看