zoukankan      html  css  js  c++  java
  • logstash 通过type判断

    [elk@zjtest7-frontend type]$ cat input.conf 
    input {
            file {
                    type => "type_a"
                    path => ["/usr/local/logstash-2.3.4/config/type/a.txt"]
            }
        
           file { 
                    type => "type_b" 
                    path => ["/usr/local/logstash-2.3.4/config/type/b.txt"] 
            } 
    
     
    }
    
    
    output {
         if [type] == "type_a" { 
            redis {
                    host => "192.168.32.67"
                    data_type => "list"
                    key => "type_a:redis"
                    port=>"6379"
                    password => "1234567"
            }
    }
          else if [type] == "type_b"{
           redis { 
                    host => "192.168.32.67" 
                    data_type => "list" 
                    key => "type_b:redis" 
                    port=>"6379" 
                    password => "1234567" 
            } 
    }
    }
    ---------------------------------------------------
    
    [elk@zjtest7-frontend type]$ cat output.conf 
    input {
    
            redis {
                    host => "192.168.32.67"
                    data_type => "list"
                    key => "type_a:redis"
                    password => "1234567"
                    port =>"6379"
            }
    
    
            redis {
                    host => "192.168.32.67"
                    data_type => "list"
                    key => "type_b:redis"
                    password => "1234567"
                    port =>"6379"
            }
    
    
    }
    output {
          if   [type] == "type_a"{ 
    		stdout {
    			codec => rubydebug
    		}
          }  
          else if  [type] == "type_b"{
                    stdout {
                            codec =>json
                    } 
      
      }
    
    }
    
    
    [elk@zjtest7-frontend type]$  ../../bin/logstash -f output.conf 
    Settings: Default pipeline workers: 1
    Pipeline main started
    {
           "message" => "aaaaaaaa",
          "@version" => "1",
        "@timestamp" => "2016-09-16T06:26:07.211Z",
              "path" => "/usr/local/logstash-2.3.4/config/type/a.txt",
              "host" => "0.0.0.0",
              "type" => "type_a"
    }
    
    
    {"message":"aaaaaaaa","@version":"1","@timestamp":"2016-09-16T06:26:31.079Z","path":"/usr/local/logstash-2.3.4/config/type/b.txt","host":"0.0.0.0","type":"type_b"}
    
    
    

  • 相关阅读:
    使用Docker快速搭建PHP开发环境
    docker-compose 使用介绍
    Google广告显示不正确的问题
    Hexo博客写作与图片处理的经验
    Docker-compose 建立ELK集群
    Flink101-快速示例
    Spark学习笔记01-基础
    Java Metrics工具介绍
    跨界
    苹果 icloud 把我 ipad min 所有照片丢失
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350254.html
Copyright © 2011-2022 走看看