logstash 贪婪匹配

 05:50:47 192.168.5.116 GET /Hotel/HotelDisplay/cncqcqb230 - 80 - 192.168.9.2 Mozilla/5.0+(Macintosh;+U;+Intel+Mac+OS+X+10.9;+en-US;+rv:1.9pre)+Gecko - 200 0 0 45


\s+(?<time>%{TIME})\s+%{IPORHOST:clientip}\s+%{WORD:verb}\s+(?<api>(\S+))\s+\-\s+(?<port>([0-9]{2}.*))\s+\-\s+


此时匹配到了:

{
  "time": [
    [
      "05:50:47"
    ]
  ],
  "clientip": [
    [
      "192.168.5.116"
    ]
  ],
  "verb": [
    [
      "GET"
    ]
  ],
  "api": [
    [
      "/Hotel/HotelDisplay/cncqcqb230"
    ]
  ],
  "port": [
    [
      "80 - 192.168.9.2 Mozilla/5.0+(Macintosh;+U;+Intel+Mac+OS+X+10.9;+en-US;+rv:1.9pre)+Gecko"
    ]
  ]
}


/*************************************************************************************

\s+(?<time>%{TIME})\s+%{IPORHOST:clientip}\s+%{WORD:verb}\s+(?<api>(\S+))\s+\-\s+(?<port>([0-9]{2}.*?))\s+\-\s+


此时正确

{
  "time": [
    [
      "05:50:47"
    ]
  ],
  "clientip": [
    [
      "192.168.5.116"
    ]
  ],
  "verb": [
    [
      "GET"
    ]
  ],
  "api": [
    [
      "/Hotel/HotelDisplay/cncqcqb230"
    ]
  ],
  "port": [
    [
      "80"
    ]
  ]
}

posted @ 2016-11-30 14:17  czcb  阅读(119)  评论(0编辑  收藏  举报