zoukankan      html  css  js  c++  java
  • logstash urldecode filter 插件

    Urldecode filter plugin
    
    设置                           输入类型             	
    	
    
    field                           字符串
    
    [elk@node01 conf]$ cat t6.conf 
    input {
       stdin{}
    }
    
    filter {  
        grok {  
            match => ["message", "%{IPORHOST:ipaddress}s*(?<aaaa>([a-z]+S+[0-9]+))s*(?<bbbb>([0-9]+S+[a-z]+)).*"]  
        } 
    }
    output {  
            stdout {  
                codec => rubydebug  
            }  
          }
    
    
    [elk@node01 conf]$ logstash -f t6.conf 
    Settings: Default pipeline workers: 4
    Pipeline main started
    10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb
    {
           "message" => "10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb",
          "@version" => "1",
        "@timestamp" => "2018-07-28T06:34:12.556Z",
              "host" => "node01",
         "ipaddress" => "10.2.3.4",
              "aaaa" => "a%E6%B3%B0%E9%9A%86999",
              "bbbb" => "99998%E6%B5%8B%E8%AF%95bbb"
    }
    
    	
    add_fileds  
    
    [elk@node01 conf]$ cat t6.conf 
    input {
       stdin{}
    }
    
    filter {  
        grok {  
            match => ["message", "%{IPORHOST:ipaddress}s*(?<aaaa>([a-z]+S+[0-9]+))s*(?<bbbb>([0-9]+S+[a-z]+)).*"]  
        } 
     mutate {
      add_field =>["eeeee","ffffff"]
     }
    }
    output {  
            stdout {  
                codec => rubydebug  
            }  
          }
    	  
    	  
    
    [elk@node01 conf]$ logstash -f t6.conf  
    Settings: Default pipeline workers: 4
    Pipeline main started
    10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb
    {
           "message" => "10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb",
          "@version" => "1",
        "@timestamp" => "2018-07-28T06:39:39.207Z",
              "host" => "node01",
         "ipaddress" => "10.2.3.4",
              "aaaa" => "a%E6%B3%B0%E9%9A%86999",
              "bbbb" => "99998%E6%B5%8B%E8%AF%95bbb",
             "eeeee" => "ffffff"
    }
    
    	
    field string:
    [elk@node01 conf]$ cat t6.conf 
    input {
       stdin{}
    }
    
    filter {  
        grok {  
            match => ["message", "%{IPORHOST:ipaddress}s*(?<aaaa>([a-z]+S+[0-9]+))s*(?<bbbb>([0-9]+S+[a-z]+)).*"]  
        } 
     mutate {
      add_field =>["eeeee","ffffff"]
     }
      urldecode{
      field=>[aaaa]
    }
    }
    output {  
            stdout {  
                codec => rubydebug  
            }  
          } 
    	  
    
    [elk@node01 conf]$ logstash -f t6.conf 
    Settings: Default pipeline workers: 4
    Pipeline main started
    10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb
    {
           "message" => "10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb",
          "@version" => "1",
        "@timestamp" => "2018-07-28T06:42:18.906Z",
              "host" => "node01",
         "ipaddress" => "10.2.3.4",
              "aaaa" => "a泰隆999",
              "bbbb" => "99998%E6%B5%8B%E8%AF%95bbb",
             "eeeee" => "ffffff"
    }
    
    	
    	
    Invalid setting for urldecode filter plugin:
    
      filter {
        urldecode {
          # This setting must be a string
          # Expected string, got ["aaaa", "bbbb"]
          field => ["aaaa", "bbbb"]
          ...
        }
      } {:level=>:error}	
    	
      urldecode{
      field=>[aaaa,bbbb]
    }
    
    这样写是不行的 
    
    [elk@node01 conf]$ cat t6.conf 
    input {
       stdin{}
    }
    
    filter {  
        grok {  
            match => ["message", "%{IPORHOST:ipaddress}s*(?<aaaa>([a-z]+S+[0-9]+))s*(?<bbbb>([0-9]+S+[a-z]+)).*"]  
        } 
     mutate {
      add_field =>["eeeee","ffffff"]
     }
      urldecode{
      field=>aaaa
    }
    }
    output {  
            stdout {  
                codec => rubydebug  
            }  
          } 
    [elk@node01 conf]$ logstash -f t6.conf 
    Settings: Default pipeline workers: 4
    Pipeline main started
    10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb
    {
           "message" => "10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb",
          "@version" => "1",
        "@timestamp" => "2018-07-28T06:47:46.966Z",
              "host" => "node01",
         "ipaddress" => "10.2.3.4",
              "aaaa" => "a泰隆999",
              "bbbb" => "99998%E6%B5%8B%E8%AF%95bbb",
             "eeeee" => "ffffff"
    }
    
    
    [elk@node01 conf]$ cat t6.conf 
    input {
       stdin{}
    }
    
    filter {  
        grok {  
            match => ["message", "%{IPORHOST:ipaddress}s*(?<aaaa>([a-z]+S+[0-9]+))s*(?<bbbb>([0-9]+S+[a-z]+)).*"]  
        } 
     mutate {
      add_field =>["eeeee","ffffff"]
     }
      urldecode{
       all_fields=>true
    }
      
    }
    output {  
            stdout {  
                codec => rubydebug  
            }  
          } 
    [elk@node01 conf]$ logstash -f t6.conf 
    Settings: Default pipeline workers: 4
    Pipeline main started
    10.2.3.4 a%E6%B3%B0%E9%9A%86999 99998%E6%B5%8B%E8%AF%95bbb
    {
           "message" => "10.2.3.4 a泰隆999 99998测试bbb",
          "@version" => "1",
        "@timestamp" => "2018-07-28T06:51:16.625Z",
              "host" => "node01",
         "ipaddress" => "10.2.3.4",
              "aaaa" => "a泰隆999",
              "bbbb" => "99998测试bbb",
             "eeeee" => "ffffff"
    }	
    	
  • 相关阅读:
    多线程博文地址 http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html
    vs2010一运行就报错deven.exe assert failure 解决方法,卸载系统中.netFramework最新版本的(简体中文)
    Lambda语句中创建自定义类型时,也可指定某种特定类型,方法是在new与{}之间写上类型名称
    Win7开始菜单所在目录
    C#中Struct与Class的区别
    Linq语句:三表联查
    用exp、dmp导入导出用户到同一个实例下时,类型type会有问题
    列、约束重命名,原数据不丢失
    CDM中,创建一个或多个组合属性的唯一约束
    EF中新建表和关联表的方法
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349076.html
Copyright © 2011-2022 走看看