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

  • 相关阅读:
    【Jdbc/Metadata】借助Metadata获得表字段的设定细节
    MASTER: Multiaspect nonlocal network for scene text recognition
    Centos8 中如何使用journalctl分析日志
    如何调试SSH连接
    如何将lvm卷移动到另一台服务器中
    CentOS8中恢复根目录为默认权限
    lightdb/postgresql中序列的使用以及oracle兼容计划
    PostgreSQL 15 Beta 1 发布
    PostgreSQL 14.3、13.7、12.11、11.16 和 10.21 发布
    MySQL/mariadb到LightDB开发迁移指南
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199221.html
Copyright © 2020-2023  润新知