• 把字符串转换为整型


    /********* 把字符串转换成整型
    zjtest7-frontend:/usr/local/logstash-2.3.4/config# cat geoip.conf
    input {stdin {} }
    
    filter {
      geoip {
       source =>"message"
      add_field => [ "[geoip][scantest]", "%{[geoip][location][0]}" ]
     }
      mutate {  
                            convert => [ "[geoip][region_name]", "integer"]  
                    }  
    } 
    
    
    output {
          stdout {
                   codec => rubydebug{}
                    } 
    }
    
    
    zjtest7-frontend:/usr/local/logstash-2.3.4/config# ../bin/logstash -f geoip.conf
    Settings: Default pipeline workers: 1
    Pipeline main started
    115.218.62.240
    {
           "message" => "115.218.62.240",
          "@version" => "1",
        "@timestamp" => "2016-09-11T04:25:13.291Z",
              "host" => "0.0.0.0",
             "geoip" => {
                          "ip" => "115.218.62.240",
               "country_code2" => "CN",
               "country_code3" => "CHN",
                "country_name" => "China",
              "continent_code" => "AS",
                 "region_name" => 2,
                   "city_name" => "Wenzhou",
                    "latitude" => 27.99940000000001,
                   "longitude" => 120.66680000000002,
                    "timezone" => "Asia/Shanghai",
            "real_region_name" => "Zhejiang",
                    "location" => [
                [0] 120.66680000000002,
                [1] 27.99940000000001
            ],
                    "scantest" => 120.66680000000002
        }
    }
    
    
    缺省:
    zjtest7-frontend:/usr/local/logstash-2.3.4/config# cat geoip.conf
    input {stdin {} }
    
    filter {
      geoip {
       source =>"message"
      add_field => [ "[geoip][scantest]", "%{[geoip][location][0]}" ]
     }
    #  mutate {  
    #                        convert => [ "[geoip][region_name]", "integer"]  
    #                }  
    } 
    
    
    output {
          stdout {
                   codec => rubydebug{}
                    } 
    }
    
    zjtest7-frontend:/usr/local/logstash-2.3.4/config# ../bin/logstash -f geoip.conf
    Settings: Default pipeline workers: 1
    Pipeline main started
    115.218.62.240
    {
           "message" => "115.218.62.240",
          "@version" => "1",
        "@timestamp" => "2016-09-11T04:26:55.758Z",
              "host" => "0.0.0.0",
             "geoip" => {
                          "ip" => "115.218.62.240",
               "country_code2" => "CN",
               "country_code3" => "CHN",
                "country_name" => "China",
              "continent_code" => "AS",
                 "region_name" => "02",
                   "city_name" => "Wenzhou",
                    "latitude" => 27.99940000000001,
                   "longitude" => 120.66680000000002,
                    "timezone" => "Asia/Shanghai",
            "real_region_name" => "Zhejiang",
                    "location" => [
                [0] 120.66680000000002,
                [1] 27.99940000000001
            ],
                    "scantest" => 120.66680000000002
        }
    }

  • 相关阅读:
    Linux配置手记及软件FAQ-更新到Fedora core 3
    怎样给多维数组动态分配内存
    mysql管理密码修改及管理权限设定(zz)
    链表处理函数(自己总结)
    二级C笔试试题
    中央广播电视大学19992000学年度第二学期“开放教育(本科)期末考试计算机科学与技术专业数据结构试题
    关闭计算机就这几招
    交大ftp校内搜索引擎终于好了!好!!
    有趣的Baidu。终于发现点比Google好的地方了
    几组重要概念
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350281.html
Copyright © 2020-2023  润新知