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

  • 相关阅读:
    非静态成员的sizeof
    Android中java.lang.ClassNotFoundException: ***.**** in loader dalvik.system.PathClassLoader[/data/app
    手机 SIM卡的EF
    android 获取手机ip的三种方式
    获取图片倒影效果
    python基础
    Python学习_数据处理split方法
    Python学习_从文件读取数据和保存数据
    Python学习_列表推导和Lambda表达式
    python学习_数据处理编程实例(一)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350276.html
Copyright © 2011-2022 走看看