• 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"
    }	
    	
  • 相关阅读:
    MVC 中的Areas支持
    webAPI 自动生成帮助文档
    ASP.NET Web API系列教程目录
    ASP.NET MVC学习系列 WebAPI初探
    win7下配置apache和php
    VS2010打不开VS2012 .NET MVC 工程,及打开后部分模块加载不正确的解决办法
    Sqlserver通过链接服务器访问Oracle的解决办法
    [C# 基础知识系列]专题一:深入解析委托——C#中为什么要引入委托
    [C# 基础知识系列]专题四:事件揭秘
    [C# 基础知识系列]专题十六:Linq介绍
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349076.html
Copyright © 2020-2023  润新知