zoukankan      html  css  js  c++  java
  • logstash 根据IP地址开头进行合并

    [elk@node01 conf]$ cat ffff.txt 
    1.1.1.1 11111
    aaaaaaa
    bbbbbbb
    2.2.2.2 222222
    ccccccc
    ddddddd
    3.3.3.3 3333333
    eeeeeee
    fffffff
    4.4.4.4 4444444
    ggggggg
    hhhhhhh
    5.5.5.5 5555555
    iiiiiii
    jjjjjjj
    kkkkkkk
    
    
    [elk@node01 conf]$ cat t7.conf 
    input {
        file {
                    type => "viewip"
                    path => ["/home/elk/conf/ffff.txt"]
                    start_position=>"beginning"
                    
            }
        
    }
    filter {
      multiline {  
      pattern => "^%{IP}"
      negate=>true  
      what=>"previous"  
     }  
    }
    
    output {
         elasticsearch {
                    hosts => "192.168.137.2:9200"
                    index => "logstash-viewip-%{+YYYY.MM.dd}"
            }
       stdout {
       codec=>rubydebug{}
     }
    }
    
    
    
    [elk@node01 conf]$ logstash -f t7.conf 
    Settings: Default pipeline workers: 4
    Defaulting pipeline worker threads to 1 because there are some filters that might not work with multiple worker threads {:count_was=>4, :filters=>["multiline"], :level=>:warn}
    Pipeline main started
    {
           "message" => "1.1.1.1 11111
    aaaaaaa
    bbbbbbb",
          "@version" => "1",
        "@timestamp" => "2018-07-31T03:07:29.776Z",
              "path" => "/home/elk/conf/ffff.txt",
              "host" => "node01",
              "type" => "viewip",
              "tags" => [
            [0] "multiline"
        ]
    }
    {
           "message" => "2.2.2.2 222222
    ccccccc
    ddddddd",
          "@version" => "1",
        "@timestamp" => "2018-07-31T03:07:30.881Z",
              "path" => "/home/elk/conf/ffff.txt",
              "host" => "node01",
              "type" => "viewip",
              "tags" => [
            [0] "multiline"
        ]
    }
    {
           "message" => "3.3.3.3 3333333
    eeeeeee
    fffffff",
          "@version" => "1",
        "@timestamp" => "2018-07-31T03:07:30.883Z",
              "path" => "/home/elk/conf/ffff.txt",
              "host" => "node01",
              "type" => "viewip",
              "tags" => [
            [0] "multiline"
        ]
    }
    {
           "message" => "4.4.4.4 4444444
    ggggggg
    hhhhhhh",
          "@version" => "1",
        "@timestamp" => "2018-07-31T03:07:30.885Z",
              "path" => "/home/elk/conf/ffff.txt",
              "host" => "node01",
              "type" => "viewip",
              "tags" => [
            [0] "multiline"
        ]
    }
    
    
    
  • 相关阅读:
    HDU 6187 Destroy Walls
    HDU1596 find the safest road
    美国机遇号失联已久,NASA想出一奇招,网友看后:这我上我也行!
    萨拉飞机或掉入恐怖深渊,那里满是核废料
    Problem : 恢复一棵树
    Problem : [tju1071]一个简单题
    Problem : 马农
    人类首个“触日”探测器绕日第二圈
    美国三岁男孩森林迷路两天 遇黑熊“热心帮忙”终获救
    世上最孤独鸭子去世
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349070.html
Copyright © 2011-2022 走看看